Chilkat Online Tools

PowerBuilder / APPIA API / GET USER DASHBOARD DETAILS

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
integer li_Success
string ls_User_id
string ls_V_Email
string ls_Names
string ls_Naira_wallet
string ls_Providus_account
string ls_Referral_link

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Adds the "Authorization: Bearer {{auth}}" header.
loo_Http.AuthToken = "{{auth}}"
loo_Http.SetRequestHeader("Content-Type","application/json")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://domain.com/users/dashboard_details",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

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

li_Success = loo_JResp.BoolOf("success")
ls_User_id = loo_JResp.StringOf("data.user_id")
ls_V_Email = loo_JResp.StringOf("data.email")
ls_Names = loo_JResp.StringOf("data.names")
ls_Naira_wallet = loo_JResp.StringOf("data.naira_wallet")
ls_Providus_account = loo_JResp.StringOf("data.providus_account")
ls_Referral_link = loo_JResp.StringOf("data.referral_link")


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_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}"
    }
  ]
}