Chilkat Online Tools

DataFlex / Belvo API Docs / Register

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sId
    String sInstitution
    String sAccess_mode
    String sLast_accessed_at
    String sStatus
    String sCreated_by
    String sRefresh_rate
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComBasicAuth Of hoHttp To True
    Set ComLogin Of hoHttp To "{{secretId}}"
    Set ComPassword Of hoHttp To "{{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.

    // {
    //   "institution": "erebor_mx_retail",
    //   "username": "username",
    //   "password": "password",
    //   "username2": "secondusername",
    //   "username3": "thirdusername",
    //   "password2": "pin",
    //   "token": "1234ab",
    //   "access_mode": "recurrent",
    //   "username_type": "001",
    //   "certificate": "1234567890abcd=",
    //   "private_key": "1234567890abcd="
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "institution" "erebor_mx_retail" To iSuccess
    Get ComUpdateString Of hoJson "username" "username" To iSuccess
    Get ComUpdateString Of hoJson "password" "password" To iSuccess
    Get ComUpdateString Of hoJson "username2" "secondusername" To iSuccess
    Get ComUpdateString Of hoJson "username3" "thirdusername" To iSuccess
    Get ComUpdateString Of hoJson "password2" "pin" To iSuccess
    Get ComUpdateString Of hoJson "token" "1234ab" To iSuccess
    Get ComUpdateString Of hoJson "access_mode" "recurrent" To iSuccess
    Get ComUpdateString Of hoJson "username_type" "001" To iSuccess
    Get ComUpdateString Of hoJson "certificate" "1234567890abcd=" To iSuccess
    Get ComUpdateString Of hoJson "private_key" "1234567890abcd=" To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://domain.com/api/links/" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    Get ComStringOf Of hoJResp "id" To sId
    Get ComStringOf Of hoJResp "institution" To sInstitution
    Get ComStringOf Of hoJResp "access_mode" To sAccess_mode
    Get ComStringOf Of hoJResp "last_accessed_at" To sLast_accessed_at
    Get ComStringOf Of hoJResp "status" To sStatus
    Get ComStringOf Of hoJResp "created_by" To sCreated_by
    Get ComStringOf Of hoJResp "refresh_rate" To sRefresh_rate


End_Procedure

Curl Command

curl -X POST
	-u '{{secretId}}:{{secretPassword}}'
	-H "Content-Type: application/json"
	-d '{
    "institution": "erebor_mx_retail",
    "username": "username",
    "password": "password",
    "username2": "secondusername",
    "username3": "thirdusername",
    "password2": "pin",
    "token": "1234ab",
    "access_mode": "recurrent",
    "username_type": "001",
    "certificate": "1234567890abcd=",
    "private_key": "1234567890abcd="
}'
https://domain.com/api/links/

Postman Collection Item JSON

{
  "name": "Register",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"institution\": \"erebor_mx_retail\",\n    \"username\": \"username\",\n    \"password\": \"password\",\n    \"username2\": \"secondusername\",\n    \"username3\": \"thirdusername\",\n    \"password2\": \"pin\",\n    \"token\": \"1234ab\",\n    \"access_mode\": \"recurrent\",\n    \"username_type\": \"001\",\n    \"certificate\": \"1234567890abcd=\",\n    \"private_key\": \"1234567890abcd=\"\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/api/links/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "links",
        ""
      ]
    },
    "description": "Register a new link with your Belvo account."
  },
  "response": [
    {
      "name": "Created",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"institution\": \"<string>\",\n    \"username\": \"<string>\",\n    \"password\": \"<string>\",\n    \"username2\": \"<string>\",\n    \"username3\": \"<string>\",\n    \"password2\": \"<string>\",\n    \"token\": \"<string>\",\n    \"encryption_key\": \"<string>\",\n    \"access_mode\": \"recurrent\",\n    \"username_type\": \"<string>\",\n    \"certificate\": \"<string>\",\n    \"private_key\": \"<string>\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/links",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "links"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_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": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"institution\": \"<string>\",\n    \"username\": \"<string>\",\n    \"password\": \"<string>\",\n    \"username2\": \"<string>\",\n    \"username3\": \"<string>\",\n    \"password2\": \"<string>\",\n    \"token\": \"<string>\",\n    \"encryption_key\": \"<string>\",\n    \"access_mode\": \"recurrent\",\n    \"username_type\": \"<string>\",\n    \"certificate\": \"<string>\",\n    \"private_key\": \"<string>\"\n}"
        },
        "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": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"institution\": \"<string>\",\n    \"username\": \"<string>\",\n    \"password\": \"<string>\",\n    \"username2\": \"<string>\",\n    \"username3\": \"<string>\",\n    \"password2\": \"<string>\",\n    \"token\": \"<string>\",\n    \"encryption_key\": \"<string>\",\n    \"access_mode\": \"recurrent\",\n    \"username_type\": \"<string>\",\n    \"certificate\": \"<string>\",\n    \"private_key\": \"<string>\"\n}"
        },
        "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": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"institution\": \"<string>\",\n    \"username\": \"<string>\",\n    \"password\": \"<string>\",\n    \"username2\": \"<string>\",\n    \"username3\": \"<string>\",\n    \"password2\": \"<string>\",\n    \"token\": \"<string>\",\n    \"encryption_key\": \"<string>\",\n    \"access_mode\": \"recurrent\",\n    \"username_type\": \"<string>\",\n    \"certificate\": \"<string>\",\n    \"private_key\": \"<string>\"\n}"
        },
        "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": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"institution\": \"<string>\",\n    \"username\": \"<string>\",\n    \"password\": \"<string>\",\n    \"username2\": \"<string>\",\n    \"username3\": \"<string>\",\n    \"password2\": \"<string>\",\n    \"token\": \"<string>\",\n    \"encryption_key\": \"<string>\",\n    \"access_mode\": \"recurrent\",\n    \"username_type\": \"<string>\",\n    \"certificate\": \"<string>\",\n    \"private_key\": \"<string>\"\n}"
        },
        "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]"
    }
  ]
}