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/accounts/:id/', @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 @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 @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 @jResp
RETURN
END
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "id": "<uuid>",
-- "link": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "institution": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "collected_at": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "category": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "type": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "number": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "balance": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "currency": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "bank_product_id": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "internal_identification": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "public_identification_name": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "public_identification_value": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "last_accessed_at": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "credit_data": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "loan_data": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "funds_data": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "gig_payment_data": {
-- "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)
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
DECLARE @Value nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'link.value'
DECLARE @institutionValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @institutionValue OUT, 'institution.value'
DECLARE @collected_atValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @collected_atValue OUT, 'collected_at.value'
DECLARE @categoryValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @categoryValue OUT, 'category.value'
DECLARE @typeValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @typeValue OUT, 'type.value'
DECLARE @nameValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @nameValue OUT, 'name.value'
DECLARE @numberValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @numberValue OUT, 'number.value'
DECLARE @balanceValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @balanceValue OUT, 'balance.value'
DECLARE @currencyValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @currencyValue OUT, 'currency.value'
DECLARE @bank_product_idValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @bank_product_idValue OUT, 'bank_product_id.value'
DECLARE @internal_identificationValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @internal_identificationValue OUT, 'internal_identification.value'
DECLARE @public_identification_nameValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @public_identification_nameValue OUT, 'public_identification_name.value'
DECLARE @public_identification_valueValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @public_identification_valueValue OUT, 'public_identification_value.value'
DECLARE @last_accessed_atValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @last_accessed_atValue OUT, 'last_accessed_at.value'
DECLARE @credit_dataValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @credit_dataValue OUT, 'credit_data.value'
DECLARE @loan_dataValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @loan_dataValue OUT, 'loan_data.value'
DECLARE @funds_dataValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @funds_dataValue OUT, 'funds_data.value'
DECLARE @gig_payment_dataValue nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @gig_payment_dataValue OUT, 'gig_payment_data.value'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X GET
-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/accounts/:id/
Postman Collection Item JSON
{
"name": "Detail",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/accounts/:id/",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"accounts",
":id",
""
],
"variable": [
{
"key": "id",
"value": "consequa",
"description": "(Required) The `account.id` you want to get detailed information about."
}
]
},
"description": "Get the details of a specific account."
},
"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/accounts/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"accounts",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n\t\"id\": \"<uuid>\",\n\t\"link\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"institution\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"collected_at\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"category\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"type\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"name\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"number\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"balance\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"currency\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"bank_product_id\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"internal_identification\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"public_identification_name\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"public_identification_value\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"last_accessed_at\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"credit_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"loan_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"funds_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"gig_payment_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\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/accounts/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"accounts",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"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]"
},
{
"name": "Too Many Sessions",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/accounts/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"accounts",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_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]"
}
]
}