Chilkat Online Tools

autoit / Belvo API Docs / Resume

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}}"

; Use this online tool to generate code from sample JSON: Generate Code to Create JSON

; The following JSON is sent in the request body.

; {
;   "session": "39cd6a88-8ee3-4e59-a861-b8a2187e0f4c",
;   "token": "1234ab",
;   "link": "683005d6-f45c-4adb-b289-f1a12f50f80c",
;   "save_data": true
; }

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("session","39cd6a88-8ee3-4e59-a861-b8a2187e0f4c")
$oJson.UpdateString("token","1234ab")
$oJson.UpdateString("link","683005d6-f45c-4adb-b289-f1a12f50f80c")
$oJson.UpdateBool("save_data",True)

$oHttp.SetRequestHeader "Content-Type","application/json"

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)

Local $oResp = $oHttp.PTextSb("PATCH","https://domain.com/api/incomes/",$oSbRequestBody,"utf-8","application/json",False,False)
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)

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

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

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @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": {
;       "id": "<uuid>",
;       "name": "<string>",
;       "currency": "<string>",
;       "category": "tempor"
;     },
;     "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": {
;       "id": "<uuid>",
;       "name": "<string>",
;       "currency": "<string>",
;       "category": "mollit dolor ex in"
;     },
;     "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 $sId
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")
    $sId = $oJson.StringOf("account.id")
    $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 PATCH
	-u '{{secretId}}:{{secretPassword}}'
	-H "Content-Type: application/json"
	-d '{
    "session": "39cd6a88-8ee3-4e59-a861-b8a2187e0f4c",
    "token": "1234ab",
    "link": "683005d6-f45c-4adb-b289-f1a12f50f80c",
    "save_data": true
}'
https://domain.com/api/incomes/

Postman Collection Item JSON

{
  "name": "Resume",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"session\": \"39cd6a88-8ee3-4e59-a861-b8a2187e0f4c\",\n    \"token\": \"1234ab\",\n    \"link\": \"683005d6-f45c-4adb-b289-f1a12f50f80c\",\n    \"save_data\": true\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/api/incomes/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "incomes",
        ""
      ]
    },
    "description": "Used to resume an Income retrieve session that was paused because an MFA token was required by the institution."
  },
  "response": [
    {
      "name": "Ok (when save_data=false)",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/incomes",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes"
          ]
        }
      },
      "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\"id\": \"<uuid>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"currency\": \"<string>\",\n\t\t\t\"category\": \"tempor\"\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\"id\": \"<uuid>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"currency\": \"<string>\",\n\t\t\t\"category\": \"mollit dolor ex in\"\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": "Created (when save_data=true)",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/incomes",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_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\"id\": \"<uuid>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"currency\": \"<string>\",\n\t\t\t\"category\": \"tempor\"\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\"id\": \"<uuid>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"currency\": \"<string>\",\n\t\t\t\"category\": \"mollit dolor ex in\"\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": "Bad request error",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/incomes",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_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": "Unauthorized",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/incomes",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes"
          ]
        }
      },
      "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": "Request Timeout",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/incomes",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes"
          ]
        }
      },
      "status": "Request Timeout",
      "code": 408,
      "_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": "MFA Token Required",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/incomes",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes"
          ]
        }
      },
      "status": "Precondition Required",
      "code": 428,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"code\": \"<string>\",\n\t\"message\": \"<string>\",\n\t\"request_id\": \"<uuid>\",\n\t\"session\": \"<uuid>\",\n\t\"expiry\": \"<integer>\",\n\t\"link\": \"<uuid>\",\n\t\"token_generation_data\": {\n\t\t\"instructions\": \"<string>\",\n\t\t\"type\": \"<string>\",\n\t\t\"value\": \"<string>\"\n\t}\n}"
    },
    {
      "name": "Unexpected Error",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/incomes",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "incomes"
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_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]"
    }
  ]
}