Chilkat Online Tools

autoit / Belvo API Docs / Detail

Back to Collection Items

; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat_9_5_0.Http")
Local $bSuccess

$oHttp.BasicAuth = True
$oHttp.Login = "{{secretId}}"
$oHttp.Password = "{{secretPassword}}"

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://domain.com/api/incomes/:id/",$oSbResponseBody)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJarrResp = ObjCreate("Chilkat_9_5_0.JsonArray")
$oJarrResp.LoadSb($oSbResponseBody)
$oJarrResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJarrResp.Emit() & @CRLF)

Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oHttp.LastHeader & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)

; [
;   {
;     "id": "<uuid>",
;     "collected_at": "<dateTime>",
;     "account": {
;       "name": "<string>",
;       "currency": "<string>",
;       "category": "adipisicing pariatur sit"
;     },
;     "currency": "<string>",
;     "sources": [
;       {
;         "transactions": [
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           },
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           }
;         ],
;         "confidence": "<string>",
;         "type": "<string>"
;       },
;       {
;         "transactions": [
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           },
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           }
;         ],
;         "confidence": "<string>",
;         "type": "<string>"
;       }
;     ]
;   },
;   {
;     "id": "<uuid>",
;     "collected_at": "<dateTime>",
;     "account": {
;       "name": "<string>",
;       "currency": "<string>",
;       "category": "exercitation consequat"
;     },
;     "currency": "<string>",
;     "sources": [
;       {
;         "transactions": [
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           },
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           }
;         ],
;         "confidence": "<string>",
;         "type": "<string>"
;       },
;       {
;         "transactions": [
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           },
;           {
;             "value": "<Error: Too many levels of nesting to fake this schema>"
;           }
;         ],
;         "confidence": "<string>",
;         "type": "<string>"
;       }
;     ]
;   }
; ]

; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

Local $oJson
Local $sId
Local $sCollected_at
Local $sName
Local $sV_Currency
Local $sCategory
Local $sV_currency
Local $iJ
Local $iCount_j
Local $sConfidence
Local $sV_type
Local $iK
Local $iCount_k
Local $sValue

Local $i = 0
Local $iCount_i = $oJarrResp.Size
While $i < $iCount_i
    $oJson = $oJarrResp.ObjectAt($i)
    $sId = $oJson.StringOf("id")
    $sCollected_at = $oJson.StringOf("collected_at")
    $sName = $oJson.StringOf("account.name")
    $sV_Currency = $oJson.StringOf("account.currency")
    $sCategory = $oJson.StringOf("account.category")
    $sV_currency = $oJson.StringOf("currency")
    $iJ = 0
    $iCount_j = $oJson.SizeOfArray("sources")
    While $iJ < $iCount_j
        $oJson.J = $iJ
        $sConfidence = $oJson.StringOf("sources[j].confidence")
        $sV_type = $oJson.StringOf("sources[j].type")
        $iK = 0
        $iCount_k = $oJson.SizeOfArray("sources[j].transactions")
        While $iK < $iCount_k
            $oJson.K = $iK
            $sValue = $oJson.StringOf("sources[j].transactions[k].value")
            $iK = $iK + 1
        Wend
        $iJ = $iJ + 1
    Wend

    $i = $i + 1
Wend

Curl Command

curl -X GET
	-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/incomes/:id/

Postman Collection Item JSON

{
  "name": "Detail",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/incomes/:id/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "incomes",
        ":id",
        ""
      ],
      "variable": [
        {
          "key": "id",
          "value": "consequa",
          "description": "(Required) The `income.id` you want to get detailed information about."
        }
      ]
    },
    "description": "Get the details of a specific income."
  },
  "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/incomes/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "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\"collected_at\": \"<dateTime>\",\n\t\t\"account\": {\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"currency\": \"<string>\",\n\t\t\t\"category\": \"adipisicing pariatur sit\"\n\t\t},\n\t\t\"currency\": \"<string>\",\n\t\t\"sources\": [\n\t\t\t{\n\t\t\t\t\"transactions\": [\n\t\t\t\t\t{\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{\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\"confidence\": \"<string>\",\n\t\t\t\t\"type\": \"<string>\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"transactions\": [\n\t\t\t\t\t{\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{\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\"confidence\": \"<string>\",\n\t\t\t\t\"type\": \"<string>\"\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\t\"id\": \"<uuid>\",\n\t\t\"collected_at\": \"<dateTime>\",\n\t\t\"account\": {\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"currency\": \"<string>\",\n\t\t\t\"category\": \"exercitation consequat\"\n\t\t},\n\t\t\"currency\": \"<string>\",\n\t\t\"sources\": [\n\t\t\t{\n\t\t\t\t\"transactions\": [\n\t\t\t\t\t{\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{\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\"confidence\": \"<string>\",\n\t\t\t\t\"type\": \"<string>\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"transactions\": [\n\t\t\t\t\t{\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{\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\"confidence\": \"<string>\",\n\t\t\t\t\"type\": \"<string>\"\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/incomes/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes",
            ":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/incomes/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes",
            ":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]"
    }
  ]
}