SQL Server / easybill REST API / Fetch positions list
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'limit', '<integer>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'page', '<integer>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'type', 'PRODUCT'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'number', '<string>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{apiKey}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://api.easybill.de/rest/v1/positions', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "page": "<integer>",
-- "pages": "<integer>",
-- "limit": "<integer>",
-- "total": "<integer>",
-- "items": [
-- {
-- "number": "<string>",
-- "description": "<string>",
-- "sale_price": "<float>",
-- "id": "<long>",
-- "type": "PRODUCT",
-- "document_note": "<string>",
-- "note": null,
-- "unit": null,
-- "export_identifier": null,
-- "export_identifier_extended": {
-- "NULL": null,
-- "nStb": null,
-- "nStbUstID": null,
-- "nStbNoneUstID": null,
-- "nStbIm": null,
-- "revc": null,
-- "IG": null,
-- "AL": null,
-- "sStfr": null,
-- "smallBusiness": null
-- },
-- "login_id": "<long>",
-- "price_type": "NETTO",
-- "vat_percent": 19,
-- "sale_price2": null,
-- "sale_price3": null,
-- "sale_price4": null,
-- "sale_price5": null,
-- "sale_price6": null,
-- "sale_price7": null,
-- "sale_price8": null,
-- "sale_price9": null,
-- "sale_price10": null,
-- "cost_price": "<float>",
-- "export_cost1": null,
-- "export_cost2": null,
-- "group_id": "<long>",
-- "stock": "NO",
-- "stock_count": 0,
-- "stock_limit_notify": false,
-- "stock_limit_notify_frequency": "ALWAYS",
-- "stock_limit": 0,
-- "quantity": null,
-- "archived": false
-- },
-- {
-- "number": "<string>",
-- "description": "<string>",
-- "sale_price": "<float>",
-- "id": "<long>",
-- "type": "PRODUCT",
-- "document_note": "<string>",
-- "note": null,
-- "unit": null,
-- "export_identifier": null,
-- "export_identifier_extended": {
-- "NULL": null,
-- "nStb": null,
-- "nStbUstID": null,
-- "nStbNoneUstID": null,
-- "nStbIm": null,
-- "revc": null,
-- "IG": null,
-- "AL": null,
-- "sStfr": null,
-- "smallBusiness": null
-- },
-- "login_id": "<long>",
-- "price_type": "NETTO",
-- "vat_percent": 19,
-- "sale_price2": null,
-- "sale_price3": null,
-- "sale_price4": null,
-- "sale_price5": null,
-- "sale_price6": null,
-- "sale_price7": null,
-- "sale_price8": null,
-- "sale_price9": null,
-- "sale_price10": null,
-- "cost_price": "<float>",
-- "export_cost1": null,
-- "export_cost2": null,
-- "group_id": "<long>",
-- "stock": "NO",
-- "stock_count": 0,
-- "stock_limit_notify": false,
-- "stock_limit_notify_frequency": "ALWAYS",
-- "stock_limit": 0,
-- "quantity": null,
-- "archived": false
-- }
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @v_number nvarchar(4000)
DECLARE @description nvarchar(4000)
DECLARE @sale_price nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @v_type nvarchar(4000)
DECLARE @document_note nvarchar(4000)
DECLARE @note nvarchar(4000)
DECLARE @unit nvarchar(4000)
DECLARE @export_identifier nvarchar(4000)
DECLARE @v_NULL nvarchar(4000)
DECLARE @NStb nvarchar(4000)
DECLARE @NStbUstID nvarchar(4000)
DECLARE @NStbNoneUstID nvarchar(4000)
DECLARE @NStbIm nvarchar(4000)
DECLARE @Revc nvarchar(4000)
DECLARE @IG nvarchar(4000)
DECLARE @AL nvarchar(4000)
DECLARE @SStfr nvarchar(4000)
DECLARE @SmallBusiness nvarchar(4000)
DECLARE @login_id nvarchar(4000)
DECLARE @price_type nvarchar(4000)
DECLARE @vat_percent int
DECLARE @sale_price2 nvarchar(4000)
DECLARE @sale_price3 nvarchar(4000)
DECLARE @sale_price4 nvarchar(4000)
DECLARE @sale_price5 nvarchar(4000)
DECLARE @sale_price6 nvarchar(4000)
DECLARE @sale_price7 nvarchar(4000)
DECLARE @sale_price8 nvarchar(4000)
DECLARE @sale_price9 nvarchar(4000)
DECLARE @sale_price10 nvarchar(4000)
DECLARE @cost_price nvarchar(4000)
DECLARE @export_cost1 nvarchar(4000)
DECLARE @export_cost2 nvarchar(4000)
DECLARE @group_id nvarchar(4000)
DECLARE @stock nvarchar(4000)
DECLARE @stock_count int
DECLARE @stock_limit_notify int
DECLARE @stock_limit_notify_frequency nvarchar(4000)
DECLARE @stock_limit int
DECLARE @quantity nvarchar(4000)
DECLARE @archived int
DECLARE @page nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @page OUT, 'page'
DECLARE @pages nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @pages OUT, 'pages'
DECLARE @limit nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @limit OUT, 'limit'
DECLARE @total nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @total OUT, 'total'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'items'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @v_number OUT, 'items[i].number'
EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'items[i].description'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price OUT, 'items[i].sale_price'
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'items[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'items[i].type'
EXEC sp_OAMethod @jResp, 'StringOf', @document_note OUT, 'items[i].document_note'
EXEC sp_OAMethod @jResp, 'StringOf', @note OUT, 'items[i].note'
EXEC sp_OAMethod @jResp, 'StringOf', @unit OUT, 'items[i].unit'
EXEC sp_OAMethod @jResp, 'StringOf', @export_identifier OUT, 'items[i].export_identifier'
EXEC sp_OAMethod @jResp, 'StringOf', @v_NULL OUT, 'items[i].export_identifier_extended.NULL'
EXEC sp_OAMethod @jResp, 'StringOf', @NStb OUT, 'items[i].export_identifier_extended.nStb'
EXEC sp_OAMethod @jResp, 'StringOf', @NStbUstID OUT, 'items[i].export_identifier_extended.nStbUstID'
EXEC sp_OAMethod @jResp, 'StringOf', @NStbNoneUstID OUT, 'items[i].export_identifier_extended.nStbNoneUstID'
EXEC sp_OAMethod @jResp, 'StringOf', @NStbIm OUT, 'items[i].export_identifier_extended.nStbIm'
EXEC sp_OAMethod @jResp, 'StringOf', @Revc OUT, 'items[i].export_identifier_extended.revc'
EXEC sp_OAMethod @jResp, 'StringOf', @IG OUT, 'items[i].export_identifier_extended.IG'
EXEC sp_OAMethod @jResp, 'StringOf', @AL OUT, 'items[i].export_identifier_extended.AL'
EXEC sp_OAMethod @jResp, 'StringOf', @SStfr OUT, 'items[i].export_identifier_extended.sStfr'
EXEC sp_OAMethod @jResp, 'StringOf', @SmallBusiness OUT, 'items[i].export_identifier_extended.smallBusiness'
EXEC sp_OAMethod @jResp, 'StringOf', @login_id OUT, 'items[i].login_id'
EXEC sp_OAMethod @jResp, 'StringOf', @price_type OUT, 'items[i].price_type'
EXEC sp_OAMethod @jResp, 'IntOf', @vat_percent OUT, 'items[i].vat_percent'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price2 OUT, 'items[i].sale_price2'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price3 OUT, 'items[i].sale_price3'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price4 OUT, 'items[i].sale_price4'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price5 OUT, 'items[i].sale_price5'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price6 OUT, 'items[i].sale_price6'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price7 OUT, 'items[i].sale_price7'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price8 OUT, 'items[i].sale_price8'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price9 OUT, 'items[i].sale_price9'
EXEC sp_OAMethod @jResp, 'StringOf', @sale_price10 OUT, 'items[i].sale_price10'
EXEC sp_OAMethod @jResp, 'StringOf', @cost_price OUT, 'items[i].cost_price'
EXEC sp_OAMethod @jResp, 'StringOf', @export_cost1 OUT, 'items[i].export_cost1'
EXEC sp_OAMethod @jResp, 'StringOf', @export_cost2 OUT, 'items[i].export_cost2'
EXEC sp_OAMethod @jResp, 'StringOf', @group_id OUT, 'items[i].group_id'
EXEC sp_OAMethod @jResp, 'StringOf', @stock OUT, 'items[i].stock'
EXEC sp_OAMethod @jResp, 'IntOf', @stock_count OUT, 'items[i].stock_count'
EXEC sp_OAMethod @jResp, 'BoolOf', @stock_limit_notify OUT, 'items[i].stock_limit_notify'
EXEC sp_OAMethod @jResp, 'StringOf', @stock_limit_notify_frequency OUT, 'items[i].stock_limit_notify_frequency'
EXEC sp_OAMethod @jResp, 'IntOf', @stock_limit OUT, 'items[i].stock_limit'
EXEC sp_OAMethod @jResp, 'StringOf', @quantity OUT, 'items[i].quantity'
EXEC sp_OAMethod @jResp, 'BoolOf', @archived OUT, 'items[i].archived'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -G -d "limit=%3Cinteger%3E"
-d "page=%3Cinteger%3E"
-d "type=PRODUCT"
-d "number=%3Cstring%3E"
-H "Authorization: {{apiKey}}"
-H "Accept: application/json"
https://api.easybill.de/rest/v1/positions
Postman Collection Item JSON
{
"name": "Fetch positions list",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/positions?limit=<integer>&page=<integer>&type=PRODUCT&number=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"positions"
],
"query": [
{
"key": "limit",
"value": "<integer>",
"description": "Limited the result. Default is 100. Maximum can be 1000."
},
{
"key": "page",
"value": "<integer>",
"description": "Set current Page. Default is 1."
},
{
"key": "type",
"value": "PRODUCT",
"description": "Filter positions by type."
},
{
"key": "number",
"value": "<string>",
"description": "Filter positions by number. You can add multiple numbers separate by comma like no,no,no."
}
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/positions?limit=<integer>&page=<integer>&type=PRODUCT&number=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"positions"
],
"query": [
{
"key": "limit",
"value": "<integer>",
"description": "Limited the result. Default is 100. Maximum can be 1000."
},
{
"key": "page",
"value": "<integer>",
"description": "Set current Page. Default is 1."
},
{
"key": "type",
"value": "PRODUCT",
"description": "Filter positions by type."
},
{
"key": "number",
"value": "<string>",
"description": "Filter positions by number. You can add multiple numbers separate by comma like no,no,no."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"page\": \"<integer>\",\n \"pages\": \"<integer>\",\n \"limit\": \"<integer>\",\n \"total\": \"<integer>\",\n \"items\": [\n {\n \"number\": \"<string>\",\n \"description\": \"<string>\",\n \"sale_price\": \"<float>\",\n \"id\": \"<long>\",\n \"type\": \"PRODUCT\",\n \"document_note\": \"<string>\",\n \"note\": null,\n \"unit\": null,\n \"export_identifier\": null,\n \"export_identifier_extended\": {\n \"NULL\": null,\n \"nStb\": null,\n \"nStbUstID\": null,\n \"nStbNoneUstID\": null,\n \"nStbIm\": null,\n \"revc\": null,\n \"IG\": null,\n \"AL\": null,\n \"sStfr\": null,\n \"smallBusiness\": null\n },\n \"login_id\": \"<long>\",\n \"price_type\": \"NETTO\",\n \"vat_percent\": 19,\n \"sale_price2\": null,\n \"sale_price3\": null,\n \"sale_price4\": null,\n \"sale_price5\": null,\n \"sale_price6\": null,\n \"sale_price7\": null,\n \"sale_price8\": null,\n \"sale_price9\": null,\n \"sale_price10\": null,\n \"cost_price\": \"<float>\",\n \"export_cost1\": null,\n \"export_cost2\": null,\n \"group_id\": \"<long>\",\n \"stock\": \"NO\",\n \"stock_count\": 0,\n \"stock_limit_notify\": false,\n \"stock_limit_notify_frequency\": \"ALWAYS\",\n \"stock_limit\": 0,\n \"quantity\": null,\n \"archived\": false\n },\n {\n \"number\": \"<string>\",\n \"description\": \"<string>\",\n \"sale_price\": \"<float>\",\n \"id\": \"<long>\",\n \"type\": \"PRODUCT\",\n \"document_note\": \"<string>\",\n \"note\": null,\n \"unit\": null,\n \"export_identifier\": null,\n \"export_identifier_extended\": {\n \"NULL\": null,\n \"nStb\": null,\n \"nStbUstID\": null,\n \"nStbNoneUstID\": null,\n \"nStbIm\": null,\n \"revc\": null,\n \"IG\": null,\n \"AL\": null,\n \"sStfr\": null,\n \"smallBusiness\": null\n },\n \"login_id\": \"<long>\",\n \"price_type\": \"NETTO\",\n \"vat_percent\": 19,\n \"sale_price2\": null,\n \"sale_price3\": null,\n \"sale_price4\": null,\n \"sale_price5\": null,\n \"sale_price6\": null,\n \"sale_price7\": null,\n \"sale_price8\": null,\n \"sale_price9\": null,\n \"sale_price10\": null,\n \"cost_price\": \"<float>\",\n \"export_cost1\": null,\n \"export_cost2\": null,\n \"group_id\": \"<long>\",\n \"stock\": \"NO\",\n \"stock_count\": 0,\n \"stock_limit_notify\": false,\n \"stock_limit_notify_frequency\": \"ALWAYS\",\n \"stock_limit\": 0,\n \"quantity\": null,\n \"archived\": false\n }\n ]\n}"
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/positions?limit=<integer>&page=<integer>&type=PRODUCT&number=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"positions"
],
"query": [
{
"key": "limit",
"value": "<integer>",
"description": "Limited the result. Default is 100. Maximum can be 1000."
},
{
"key": "page",
"value": "<integer>",
"description": "Set current Page. Default is 1."
},
{
"key": "type",
"value": "PRODUCT",
"description": "Filter positions by type."
},
{
"key": "number",
"value": "<string>",
"description": "Filter positions by number. You can add multiple numbers separate by comma like no,no,no."
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}