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
-- 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
EXEC sp_OASetProperty @http, 'BasicAuth', 1
EXEC sp_OASetProperty @http, 'Login', '{{secretId}}'
EXEC sp_OASetProperty @http, 'Password', '{{secretPassword}}'
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 @http, 'QuickGetSb', @success OUT, 'https://domain.com/api/tax-returns/', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jarrResp int
-- Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonArray', @jarrResp OUT
EXEC sp_OAMethod @jarrResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jarrResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jarrResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jarrResp
RETURN
END
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- [
-- {
-- "id": "<uuid>",
-- "link": "<uuid>",
-- "collected_at": "<dateTime>",
-- "informacion_general": "<object>",
-- "sueldos_salarios": "<object>",
-- "servicios_profesionales": "<object>",
-- "deducciones_personales": "<object>",
-- "determinacion_impuesto": "<object>",
-- "retenciones": "<object>",
-- "dividendos": "<object>",
-- "datos_informativos": "<object>",
-- "pdf": "<binary>"
-- },
-- {
-- "id": "<uuid>",
-- "link": "<uuid>",
-- "collected_at": "<dateTime>",
-- "informacion_general": "<object>",
-- "sueldos_salarios": "<object>",
-- "servicios_profesionales": "<object>",
-- "deducciones_personales": "<object>",
-- "determinacion_impuesto": "<object>",
-- "retenciones": "<object>",
-- "dividendos": "<object>",
-- "datos_informativos": "<object>",
-- "pdf": "<binary>"
-- }
-- ]
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @json int
DECLARE @id nvarchar(4000)
DECLARE @link nvarchar(4000)
DECLARE @collected_at nvarchar(4000)
DECLARE @informacion_general nvarchar(4000)
DECLARE @sueldos_salarios nvarchar(4000)
DECLARE @servicios_profesionales nvarchar(4000)
DECLARE @deducciones_personales nvarchar(4000)
DECLARE @determinacion_impuesto nvarchar(4000)
DECLARE @retenciones nvarchar(4000)
DECLARE @dividendos nvarchar(4000)
DECLARE @datos_informativos nvarchar(4000)
DECLARE @pdf nvarchar(4000)
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAGetProperty @jarrResp, 'Size', @count_i OUT
WHILE @i < @count_i
BEGIN
EXEC sp_OAMethod @jarrResp, 'ObjectAt', @json OUT, @i
EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'id'
EXEC sp_OAMethod @json, 'StringOf', @link OUT, 'link'
EXEC sp_OAMethod @json, 'StringOf', @collected_at OUT, 'collected_at'
EXEC sp_OAMethod @json, 'StringOf', @informacion_general OUT, 'informacion_general'
EXEC sp_OAMethod @json, 'StringOf', @sueldos_salarios OUT, 'sueldos_salarios'
EXEC sp_OAMethod @json, 'StringOf', @servicios_profesionales OUT, 'servicios_profesionales'
EXEC sp_OAMethod @json, 'StringOf', @deducciones_personales OUT, 'deducciones_personales'
EXEC sp_OAMethod @json, 'StringOf', @determinacion_impuesto OUT, 'determinacion_impuesto'
EXEC sp_OAMethod @json, 'StringOf', @retenciones OUT, 'retenciones'
EXEC sp_OAMethod @json, 'StringOf', @dividendos OUT, 'dividendos'
EXEC sp_OAMethod @json, 'StringOf', @datos_informativos OUT, 'datos_informativos'
EXEC sp_OAMethod @json, 'StringOf', @pdf OUT, 'pdf'
EXEC @hr = sp_OADestroy @json
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jarrResp
END
GO
Curl Command
curl -X GET
-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/tax-returns/
Postman Collection Item JSON
{
"name": "List",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/tax-returns/",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"tax-returns",
""
],
"query": [
{
"key": "page",
"value": "1",
"description": "A page number within the paginated result set.",
"disabled": true
}
]
},
"description": "Get a paginated list of all existing tax returns in your Belvo account. We return up to 100 results per page.\n\nThe results will include a mix of both monthly and yearly tax returns."
},
"response": [
{
"name": "Ok",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/tax-returns?page=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"tax-returns"
],
"query": [
{
"key": "page",
"value": "<integer>"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "[\n\t{\n\t\t\"id\": \"<uuid>\",\n\t\t\"link\": \"<uuid>\",\n\t\t\"collected_at\": \"<dateTime>\",\n\t\t\"informacion_general\": \"<object>\",\n\t\t\"sueldos_salarios\": \"<object>\",\n\t\t\"servicios_profesionales\": \"<object>\",\n\t\t\"deducciones_personales\": \"<object>\",\n\t\t\"determinacion_impuesto\": \"<object>\",\n\t\t\"retenciones\": \"<object>\",\n\t\t\"dividendos\": \"<object>\",\n\t\t\"datos_informativos\": \"<object>\",\n\t\t\"pdf\": \"<binary>\"\n\t},\n\t{\n\t\t\"id\": \"<uuid>\",\n\t\t\"link\": \"<uuid>\",\n\t\t\"collected_at\": \"<dateTime>\",\n\t\t\"informacion_general\": \"<object>\",\n\t\t\"sueldos_salarios\": \"<object>\",\n\t\t\"servicios_profesionales\": \"<object>\",\n\t\t\"deducciones_personales\": \"<object>\",\n\t\t\"determinacion_impuesto\": \"<object>\",\n\t\t\"retenciones\": \"<object>\",\n\t\t\"dividendos\": \"<object>\",\n\t\t\"datos_informativos\": \"<object>\",\n\t\t\"pdf\": \"<binary>\"\n\t}\n]"
},
{
"name": "Unauthorized",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/tax-returns?page=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"tax-returns"
],
"query": [
{
"key": "page",
"value": "<integer>"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "[\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t},\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t}\n]"
}
]
}