Chilkat Online Tools

Node.js / Belvo API Docs / Detail

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

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

    var http = new chilkat.Http();
    var success;

    http.BasicAuth = true;
    http.Login = "{{secretId}}";
    http.Password = "{{secretPassword}}";

    var sbResponseBody = new chilkat.StringBuilder();
    success = http.QuickGetSb("https://domain.com/api/owners/:id/",sbResponseBody);
    if (success == false) {
        console.log(http.LastErrorText);
        return;
    }

    var jResp = new chilkat.JsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.EmitCompact = false;

    console.log("Response Body:");
    console.log(jResp.Emit());

    var respStatusCode = http.LastStatus;
    console.log("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        console.log("Response Header:");
        console.log(http.LastHeader);
        console.log("Failed.");
        return;
    }

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

    // {
    //   "id": "<uuid>",
    //   "link": "<uuid>",
    //   "collected_at": "<dateTime>",
    //   "display_name": "<string>",
    //   "first_name": "<string>",
    //   "last_name": "<string>",
    //   "second_last_name": "<string>",
    //   "address": "<string>",
    //   "email": "<email>",
    //   "phone_number": "<string>",
    //   "accounts": [
    //     {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     },
    //     {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   ],
    //   "gig_data": {
    //     "collected_at": "<dateTime>",
    //     "status": "<string>",
    //     "acceptance_rate": "<number>"
    //   }
    // }

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

    var value;

    var id = jResp.StringOf("id");
    var link = jResp.StringOf("link");
    var collected_at = jResp.StringOf("collected_at");
    var display_name = jResp.StringOf("display_name");
    var first_name = jResp.StringOf("first_name");
    var last_name = jResp.StringOf("last_name");
    var second_last_name = jResp.StringOf("second_last_name");
    var address = jResp.StringOf("address");
    var email = jResp.StringOf("email");
    var phone_number = jResp.StringOf("phone_number");
    var Collected_at = jResp.StringOf("gig_data.collected_at");
    var Status = jResp.StringOf("gig_data.status");
    var Acceptance_rate = jResp.StringOf("gig_data.acceptance_rate");
    var i = 0;
    var count_i = jResp.SizeOfArray("accounts");
    while (i < count_i) {
        jResp.I = i;
        value = jResp.StringOf("accounts[i].value");
        i = i+1;
    }


}

chilkatExample();

Curl Command

curl -X GET
	-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/owners/:id/

Postman Collection Item JSON

{
  "name": "Detail",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/owners/:id/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "owners",
        ":id",
        ""
      ],
      "variable": [
        {
          "key": "id",
          "value": "consequa",
          "description": "(Required) The `owner.id` you want to get detailed information about."
        }
      ]
    },
    "description": "Get the details of a specific owner."
  },
  "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/owners/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "owners",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"id\": \"<uuid>\",\n\t\"link\": \"<uuid>\",\n\t\"collected_at\": \"<dateTime>\",\n\t\"display_name\": \"<string>\",\n\t\"first_name\": \"<string>\",\n\t\"last_name\": \"<string>\",\n\t\"second_last_name\": \"<string>\",\n\t\"address\": \"<string>\",\n\t\"email\": \"<email>\",\n\t\"phone_number\": \"<string>\",\n\t\"accounts\": [\n\t\t{\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t{\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t}\n\t],\n\t\"gig_data\": {\n\t\t\"collected_at\": \"<dateTime>\",\n\t\t\"status\": \"<string>\",\n\t\t\"acceptance_rate\": \"<number>\"\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/owners/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "owners",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "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": "Too Many Sessions",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/owners/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "owners",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_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]"
    }
  ]
}