Chilkat Online Tools

Foxpro / Belvo API Docs / List

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loQueryParams
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcId
LOCAL lcName
LOCAL lcV_type
LOCAL lcWebsite
LOCAL lcDisplay_name
LOCAL lcPrimary_color
LOCAL lcLogo
LOCAL lcIcon_logo
LOCAL lcText_logo
LOCAL j
LOCAL lnCount_j
LOCAL lcStrVal
LOCAL lcValue
LOCAL lcTypeValue
LOCAL lcLabelValue
LOCAL lcValidationValue
LOCAL lcPlaceholderValue
LOCAL lcValidation_messageValue
LOCAL lcValueValue
LOCAL lcNameValue
LOCAL lcDescriptionValue
LOCAL lcCount
LOCAL lcV_next
LOCAL lcPrevious
LOCAL i
LOCAL lnCount_i

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

loHttp.BasicAuth = 1
loHttp.Login = "{{secretId}}"
loHttp.Password = "{{secretPassword}}"

loQueryParams = CreateObject('Chilkat_9_5_0.JsonObject')
loQueryParams.UpdateInt("page",1)

loResp = loHttp.QuickRequestParams("GET","https://domain.com/api/institutions/",loQueryParams)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loQueryParams
    CANCEL
ENDIF

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loQueryParams
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

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

* {
*   "count": "<integer>",
*   "next": "<string>",
*   "previous": "<string>",
*   "results": [
*     {
*       "id": "<string>",
*       "name": "<string>",
*       "type": "culpa dolore in",
*       "website": "<string>",
*       "display_name": "<string>",
*       "country_codes": [
*         "<string>",
*         "<string>"
*       ],
*       "primary_color": "<string>",
*       "logo": "<string>",
*       "icon_logo": "<string>",
*       "text_logo": "<string>",
*       "form_fields": [
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "type": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "label": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "placeholder": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation_message": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "value": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           }
*         },
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "type": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "label": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "placeholder": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation_message": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "value": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           }
*         }
*       ],
*       "features": [
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "description": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           }
*         },
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "description": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           }
*         }
*       ]
*     },
*     {
*       "id": "<string>",
*       "name": "<string>",
*       "type": "incididunt ut",
*       "website": "<string>",
*       "display_name": "<string>",
*       "country_codes": [
*         "<string>",
*         "<string>"
*       ],
*       "primary_color": "<string>",
*       "logo": "<string>",
*       "icon_logo": "<string>",
*       "text_logo": "<string>",
*       "form_fields": [
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "type": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "label": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "placeholder": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation_message": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "value": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           }
*         },
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "type": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "label": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "placeholder": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "validation_message": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "value": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           }
*         }
*       ],
*       "features": [
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "description": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           }
*         },
*         {
*           "name": {
*             "value": "<Error: Too many levels of nesting to fake this schema>"
*           },
*           "description": {
*             "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

lcCount = loJResp.StringOf("count")
lcV_next = loJResp.StringOf("next")
lcPrevious = loJResp.StringOf("previous")
i = 0
lnCount_i = loJResp.SizeOfArray("results")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcId = loJResp.StringOf("results[i].id")
    lcName = loJResp.StringOf("results[i].name")
    lcV_type = loJResp.StringOf("results[i].type")
    lcWebsite = loJResp.StringOf("results[i].website")
    lcDisplay_name = loJResp.StringOf("results[i].display_name")
    lcPrimary_color = loJResp.StringOf("results[i].primary_color")
    lcLogo = loJResp.StringOf("results[i].logo")
    lcIcon_logo = loJResp.StringOf("results[i].icon_logo")
    lcText_logo = loJResp.StringOf("results[i].text_logo")
    j = 0
    lnCount_j = loJResp.SizeOfArray("results[i].country_codes")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("results[i].country_codes[j]")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("results[i].form_fields")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcValue = loJResp.StringOf("results[i].form_fields[j].name.value")
        lcTypeValue = loJResp.StringOf("results[i].form_fields[j].type.value")
        lcLabelValue = loJResp.StringOf("results[i].form_fields[j].label.value")
        lcValidationValue = loJResp.StringOf("results[i].form_fields[j].validation.value")
        lcPlaceholderValue = loJResp.StringOf("results[i].form_fields[j].placeholder.value")
        lcValidation_messageValue = loJResp.StringOf("results[i].form_fields[j].validation_message.value")
        lcValueValue = loJResp.StringOf("results[i].form_fields[j].value.value")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("results[i].features")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcNameValue = loJResp.StringOf("results[i].features[j].name.value")
        lcDescriptionValue = loJResp.StringOf("results[i].features[j].description.value")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loQueryParams
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl -G -d "page=1"
	-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/institutions/

Postman Collection Item JSON

{
  "name": "List",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/institutions/?page=1",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "institutions",
        ""
      ],
      "query": [
        {
          "key": "page",
          "value": "1",
          "description": "A page number within the paginated result set."
        }
      ]
    },
    "description": "Get a paginated list of all the institutions currently supported by Belvo. We return up to 100 results per page."
  },
  "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/institutions?page=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "institutions"
          ],
          "query": [
            {
              "key": "page",
              "value": "<integer>"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"count\": \"<integer>\",\n\t\"next\": \"<string>\",\n\t\"previous\": \"<string>\",\n\t\"results\": [\n\t\t{\n\t\t\t\"id\": \"<string>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"type\": \"culpa dolore in\",\n\t\t\t\"website\": \"<string>\",\n\t\t\t\"display_name\": \"<string>\",\n\t\t\t\"country_codes\": [\n\t\t\t\t\"<string>\",\n\t\t\t\t\"<string>\"\n\t\t\t],\n\t\t\t\"primary_color\": \"<string>\",\n\t\t\t\"logo\": \"<string>\",\n\t\t\t\"icon_logo\": \"<string>\",\n\t\t\t\"text_logo\": \"<string>\",\n\t\t\t\"form_fields\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\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\"type\": {\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\"label\": {\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\"validation\": {\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\"placeholder\": {\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\"validation_message\": {\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\"value\": {\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{\n\t\t\t\t\t\"name\": {\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\"type\": {\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\"label\": {\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\"validation\": {\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\"placeholder\": {\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\"validation_message\": {\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\"value\": {\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],\n\t\t\t\"features\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\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\"description\": {\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{\n\t\t\t\t\t\"name\": {\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\"description\": {\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]\n\t\t},\n\t\t{\n\t\t\t\"id\": \"<string>\",\n\t\t\t\"name\": \"<string>\",\n\t\t\t\"type\": \"incididunt ut\",\n\t\t\t\"website\": \"<string>\",\n\t\t\t\"display_name\": \"<string>\",\n\t\t\t\"country_codes\": [\n\t\t\t\t\"<string>\",\n\t\t\t\t\"<string>\"\n\t\t\t],\n\t\t\t\"primary_color\": \"<string>\",\n\t\t\t\"logo\": \"<string>\",\n\t\t\t\"icon_logo\": \"<string>\",\n\t\t\t\"text_logo\": \"<string>\",\n\t\t\t\"form_fields\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\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\"type\": {\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\"label\": {\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\"validation\": {\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\"placeholder\": {\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\"validation_message\": {\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\"value\": {\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{\n\t\t\t\t\t\"name\": {\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\"type\": {\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\"label\": {\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\"validation\": {\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\"placeholder\": {\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\"validation_message\": {\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\"value\": {\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],\n\t\t\t\"features\": [\n\t\t\t\t{\n\t\t\t\t\t\"name\": {\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\"description\": {\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{\n\t\t\t\t\t\"name\": {\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\"description\": {\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]\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/institutions?page=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "institutions"
          ],
          "query": [
            {
              "key": "page",
              "value": "<integer>"
            }
          ]
        }
      },
      "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]"
    }
  ]
}