Chilkat Online Tools

Xojo / 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.

Dim http As New Chilkat.Http
Dim success As Boolean

http.BasicAuth = True
http.Login = "{{secretId}}"
http.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"
// }

Dim json As New Chilkat.JsonObject
success = json.UpdateString("session","39cd6a88-8ee3-4e59-a861-b8a2187e0f4c")
success = json.UpdateString("token","1234ab")
success = json.UpdateString("link","683005d6-f45c-4adb-b289-f1a12f50f80c")

http.SetRequestHeader "Content-Type","application/json"

Dim sbRequestBody As New Chilkat.StringBuilder
success = json.EmitSb(sbRequestBody)

Dim resp As Chilkat.HttpResponse
resp = http.PTextSb("PATCH","https://domain.com/api/links/",sbRequestBody,"utf-8","application/json",False,False)
If (http.LastMethodSuccess = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

Dim sbResponseBody As New Chilkat.StringBuilder
success = resp.GetBodySb(sbResponseBody)

Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = resp.StatusCode
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(resp.Header)
    System.DebugLog("Failed.")

    Return
End If

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

// {
//   "id": "<uuid>",
//   "institution": "<string>",
//   "access_mode": "<string>",
//   "last_accessed_at": "<dateTime>",
//   "status": "<string>",
//   "created_by": "<uuid>",
//   "refresh_rate": "<string>"
// }

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

Dim id As String
id = jResp.StringOf("id")
Dim institution As String
institution = jResp.StringOf("institution")
Dim access_mode As String
access_mode = jResp.StringOf("access_mode")
Dim last_accessed_at As String
last_accessed_at = jResp.StringOf("last_accessed_at")
Dim status As String
status = jResp.StringOf("status")
Dim created_by As String
created_by = jResp.StringOf("created_by")
Dim refresh_rate As String
refresh_rate = jResp.StringOf("refresh_rate")

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"
}'
https://domain.com/api/links/

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}"
    },
    "url": {
      "raw": "{{baseUrl}}/api/links/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "links",
        ""
      ]
    },
    "description": "Used to resume a Link register session that was paused because an MFA token was required by the institution."
  },
  "response": [
    {
      "name": "Ok",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/links",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "links"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"id\": \"<uuid>\",\n\t\"institution\": \"<string>\",\n\t\"access_mode\": \"<string>\",\n\t\"last_accessed_at\": \"<dateTime>\",\n\t\"status\": \"<string>\",\n\t\"created_by\": \"<uuid>\",\n\t\"refresh_rate\": \"<string>\"\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/links",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "links"
          ]
        }
      },
      "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/links",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "links"
          ]
        }
      },
      "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": "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/links",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "links"
          ]
        }
      },
      "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/links",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "links"
          ]
        }
      },
      "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]"
    }
  ]
}