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
EXEC sp_OASetProperty @http, 'BasicAuth', 1
EXEC sp_OASetProperty @http, 'Login', '{{secretId}}'
EXEC sp_OASetProperty @http, 'Password', '{{secretPassword}}'
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, 'UpdateInt', @success OUT, 'page', 1
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://domain.com/api/institutions/', @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)
-- {
-- "count": "<integer>",
-- "next": "<string>",
-- "previous": "<string>",
-- "results": [
-- {
-- "id": "<string>",
-- "name": "<string>",
-- "type": "culpa dolore in",
-- "website": "<string>",
-- "display_name": "<string>",
-- "country_codes": [
-- "<string>",
-- "<string>"
-- ],
-- "primary_color": "<string>",
-- "logo": "<string>",
-- "icon_logo": "<string>",
-- "text_logo": "<string>",
-- "form_fields": [
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "type": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "label": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "placeholder": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation_message": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "value": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "type": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "label": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "placeholder": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation_message": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "value": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- }
-- ],
-- "features": [
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "description": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "description": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- }
-- ]
-- },
-- {
-- "id": "<string>",
-- "name": "<string>",
-- "type": "incididunt ut",
-- "website": "<string>",
-- "display_name": "<string>",
-- "country_codes": [
-- "<string>",
-- "<string>"
-- ],
-- "primary_color": "<string>",
-- "logo": "<string>",
-- "icon_logo": "<string>",
-- "text_logo": "<string>",
-- "form_fields": [
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "type": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "label": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "placeholder": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation_message": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "value": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "type": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "label": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "placeholder": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "validation_message": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "value": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- }
-- ],
-- "features": [
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "description": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- {
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "description": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- }
-- ]
-- }
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @id nvarchar(4000)
DECLARE @name nvarchar(4000)
DECLARE @v_type nvarchar(4000)
DECLARE @website nvarchar(4000)
DECLARE @display_name nvarchar(4000)
DECLARE @primary_color nvarchar(4000)
DECLARE @logo nvarchar(4000)
DECLARE @icon_logo nvarchar(4000)
DECLARE @text_logo nvarchar(4000)
DECLARE @j int
DECLARE @count_j int
DECLARE @strVal nvarchar(4000)
DECLARE @Value nvarchar(4000)
DECLARE @typeValue nvarchar(4000)
DECLARE @labelValue nvarchar(4000)
DECLARE @validationValue nvarchar(4000)
DECLARE @placeholderValue nvarchar(4000)
DECLARE @validation_messageValue nvarchar(4000)
DECLARE @valueValue nvarchar(4000)
DECLARE @nameValue nvarchar(4000)
DECLARE @descriptionValue nvarchar(4000)
DECLARE @count nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @count OUT, 'count'
DECLARE @v_next nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_next OUT, 'next'
DECLARE @previous nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @previous OUT, 'previous'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'results'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'results[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'results[i].name'
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'results[i].type'
EXEC sp_OAMethod @jResp, 'StringOf', @website OUT, 'results[i].website'
EXEC sp_OAMethod @jResp, 'StringOf', @display_name OUT, 'results[i].display_name'
EXEC sp_OAMethod @jResp, 'StringOf', @primary_color OUT, 'results[i].primary_color'
EXEC sp_OAMethod @jResp, 'StringOf', @logo OUT, 'results[i].logo'
EXEC sp_OAMethod @jResp, 'StringOf', @icon_logo OUT, 'results[i].icon_logo'
EXEC sp_OAMethod @jResp, 'StringOf', @text_logo OUT, 'results[i].text_logo'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].country_codes'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'results[i].country_codes[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].form_fields'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'results[i].form_fields[j].name.value'
EXEC sp_OAMethod @jResp, 'StringOf', @typeValue OUT, 'results[i].form_fields[j].type.value'
EXEC sp_OAMethod @jResp, 'StringOf', @labelValue OUT, 'results[i].form_fields[j].label.value'
EXEC sp_OAMethod @jResp, 'StringOf', @validationValue OUT, 'results[i].form_fields[j].validation.value'
EXEC sp_OAMethod @jResp, 'StringOf', @placeholderValue OUT, 'results[i].form_fields[j].placeholder.value'
EXEC sp_OAMethod @jResp, 'StringOf', @validation_messageValue OUT, 'results[i].form_fields[j].validation_message.value'
EXEC sp_OAMethod @jResp, 'StringOf', @valueValue OUT, 'results[i].form_fields[j].value.value'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].features'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @nameValue OUT, 'results[i].features[j].name.value'
EXEC sp_OAMethod @jResp, 'StringOf', @descriptionValue OUT, 'results[i].features[j].description.value'
SELECT @j = @j + 1
END
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 "page=1"
-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/institutions/
Postman Collection Item JSON
{
"name": "List",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/institutions/?page=1",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"institutions",
""
],
"query": [
{
"key": "page",
"value": "1",
"description": "A page number within the paginated result set."
}
]
},
"description": "Get a paginated list of all the institutions currently supported by Belvo. We return up to 100 results per page."
},
"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/institutions?page=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"institutions"
],
"query": [
{
"key": "page",
"value": "<integer>"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n\t\"count\": \"<integer>\",\n\t\"next\": \"<string>\",\n\t\"previous\": \"<string>\",\n\t\"results\": [\n\t\t{\n\t\t\t\"id\": \"<string>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"type\": \"culpa dolore in\",\n\t\t\t\"website\": \"<string>\",\n\t\t\t\"display_name\": \"<string>\",\n\t\t\t\"country_codes\": [\n\t\t\t\t\"<string>\",\n\t\t\t\t\"<string>\"\n\t\t\t],\n\t\t\t\"primary_color\": \"<string>\",\n\t\t\t\"logo\": \"<string>\",\n\t\t\t\"icon_logo\": \"<string>\",\n\t\t\t\"text_logo\": \"<string>\",\n\t\t\t\"form_fields\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"label\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"placeholder\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation_message\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"value\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"label\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"placeholder\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation_message\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"value\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"features\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"description\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"description\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"id\": \"<string>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"type\": \"incididunt ut\",\n\t\t\t\"website\": \"<string>\",\n\t\t\t\"display_name\": \"<string>\",\n\t\t\t\"country_codes\": [\n\t\t\t\t\"<string>\",\n\t\t\t\t\"<string>\"\n\t\t\t],\n\t\t\t\"primary_color\": \"<string>\",\n\t\t\t\"logo\": \"<string>\",\n\t\t\t\"icon_logo\": \"<string>\",\n\t\t\t\"text_logo\": \"<string>\",\n\t\t\t\"form_fields\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"label\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"placeholder\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation_message\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"value\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"label\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"placeholder\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"validation_message\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"value\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t],\n\t\t\t\"features\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"description\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t},\n\t\t\t\t\t\"description\": {\n\t\t\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\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/institutions?page=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"institutions"
],
"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]"
}
]
}