Chilkat Online Tools

unicodeC / APPIA API / GET USER DASHBOARD DETAILS

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    BOOL success;
    const wchar_t *User_id;
    const wchar_t *v_Email;
    const wchar_t *Names;
    const wchar_t *Naira_wallet;
    const wchar_t *Providus_account;
    const wchar_t *Referral_link;

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

    http = CkHttpW_Create();

    // Adds the "Authorization: Bearer {{auth}}" header.
    CkHttpW_putAuthToken(http,L"{{auth}}");
    CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkHttpW_QuickGetSb(http,L"https://domain.com/users/dashboard_details",sbResponseBody);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",CkJsonObjectW_emit(jResp));

    respStatusCode = CkHttpW_getLastStatus(http);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpW_lastHeader(http));
        wprintf(L"Failed.\n");
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

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

    // {
    //   "success": true,
    //   "data": {
    //     "user_id": "RJ7qynWWe",
    //     "email": "tosinolugbenga@gmail.com",
    //     "names": "Tosin Olugbenga",
    //     "naira_wallet": "0.00",
    //     "providus_account": "4000040054",
    //     "referral_link": "https://Appia.com/register?ref=undefined"
    //   }
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    success = CkJsonObjectW_BoolOf(jResp,L"success");
    User_id = CkJsonObjectW_stringOf(jResp,L"data.user_id");
    v_Email = CkJsonObjectW_stringOf(jResp,L"data.email");
    Names = CkJsonObjectW_stringOf(jResp,L"data.names");
    Naira_wallet = CkJsonObjectW_stringOf(jResp,L"data.naira_wallet");
    Providus_account = CkJsonObjectW_stringOf(jResp,L"data.providus_account");
    Referral_link = CkJsonObjectW_stringOf(jResp,L"data.referral_link");


    CkHttpW_Dispose(http);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "Authorization: Bearer {{auth}}"
https://domain.com/users/dashboard_details

Postman Collection Item JSON

{
  "name": "GET USER DASHBOARD DETAILS",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{auth}}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "disabled": true
      },
      {
        "key": "Authorization",
        "value": "Bearer {{auth}}",
        "disabled": true
      }
    ],
    "url": {
      "raw": "{{url}}/users/dashboard_details",
      "host": [
        "{{url}}"
      ],
      "path": [
        "users",
        "dashboard_details"
      ]
    },
    "description": "User profile update"
  },
  "response": [
    {
      "name": "GET USER DASHBOARD DETAILS",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "disabled": true
          },
          {
            "key": "Authorization",
            "value": "Bearer {{auth}}",
            "disabled": true
          }
        ],
        "url": {
          "raw": "{{url}}/users/dashboard_details",
          "host": [
            "{{url}}"
          ],
          "path": [
            "users",
            "dashboard_details"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "Cowboy"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "X-Powered-By",
          "value": "Express"
        },
        {
          "key": "Access-Control-Allow-Origin",
          "value": "*"
        },
        {
          "key": "Content-Type",
          "value": "application/json; charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "221"
        },
        {
          "key": "Etag",
          "value": "W/\"dd-/TJsOdEDY8RgDebDUsbizdQV45I\""
        },
        {
          "key": "Date",
          "value": "Tue, 08 Dec 2020 20:16:58 GMT"
        },
        {
          "key": "Via",
          "value": "1.1 vegur"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"success\": true,\n    \"data\": {\n        \"user_id\": \"RJ7qynWWe\",\n        \"email\": \"tosinolugbenga@gmail.com\",\n        \"names\": \"Tosin Olugbenga\",\n        \"naira_wallet\": \"0.00\",\n        \"providus_account\": \"4000040054\",\n        \"referral_link\": \"https://Appia.com/register?ref=undefined\"\n    }\n}"
    }
  ]
}