Chilkat Online Tools

Android / Belvo API Docs / List

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    http.put_BasicAuth(true);
    http.put_Login("{{secretId}}");
    http.put_Password("{{secretPassword}}");

    CkJsonObject queryParams = new CkJsonObject();
    queryParams.UpdateInt("page",1);

    CkHttpResponse resp = http.QuickRequestParams("GET","https://domain.com/api/institutions/",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    resp.GetBodySb(sbResponseBody);

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jResp.emit());

    int respStatusCode = resp.get_StatusCode();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, resp.header());
        Log.i(TAG, "Failed.");

        return;
        }

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

    String id;
    String name;
    String v_type;
    String website;
    String display_name;
    String primary_color;
    String logo;
    String icon_logo;
    String text_logo;
    int j;
    int count_j;
    String strVal;
    String Value;
    String typeValue;
    String labelValue;
    String validationValue;
    String placeholderValue;
    String validation_messageValue;
    String valueValue;
    String nameValue;
    String descriptionValue;

    String count = jResp.stringOf("count");
    String v_next = jResp.stringOf("next");
    String previous = jResp.stringOf("previous");
    int i = 0;
    int count_i = jResp.SizeOfArray("results");
    while (i < count_i) {
        jResp.put_I(i);
        id = jResp.stringOf("results[i].id");
        name = jResp.stringOf("results[i].name");
        v_type = jResp.stringOf("results[i].type");
        website = jResp.stringOf("results[i].website");
        display_name = jResp.stringOf("results[i].display_name");
        primary_color = jResp.stringOf("results[i].primary_color");
        logo = jResp.stringOf("results[i].logo");
        icon_logo = jResp.stringOf("results[i].icon_logo");
        text_logo = jResp.stringOf("results[i].text_logo");
        j = 0;
        count_j = jResp.SizeOfArray("results[i].country_codes");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf("results[i].country_codes[j]");
            j = j + 1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("results[i].form_fields");
        while (j < count_j) {
            jResp.put_J(j);
            Value = jResp.stringOf("results[i].form_fields[j].name.value");
            typeValue = jResp.stringOf("results[i].form_fields[j].type.value");
            labelValue = jResp.stringOf("results[i].form_fields[j].label.value");
            validationValue = jResp.stringOf("results[i].form_fields[j].validation.value");
            placeholderValue = jResp.stringOf("results[i].form_fields[j].placeholder.value");
            validation_messageValue = jResp.stringOf("results[i].form_fields[j].validation_message.value");
            valueValue = jResp.stringOf("results[i].form_fields[j].value.value");
            j = j + 1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("results[i].features");
        while (j < count_j) {
            jResp.put_J(j);
            nameValue = jResp.stringOf("results[i].features[j].name.value");
            descriptionValue = jResp.stringOf("results[i].features[j].description.value");
            j = j + 1;
            }

        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

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