DataFlex / APPIA API / GET USER DASHBOARD DETAILS
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
Boolean iSuccess
String sUser_id
String sV_Email
String sNames
String sNaira_wallet
String sProvidus_account
String sReferral_link
String sTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Adds the "Authorization: Bearer {{auth}}" header.
Set ComAuthToken Of hoHttp To "{{auth}}"
Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://domain.com/users/dashboard_details" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// 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
Get ComBoolOf Of hoJResp "success" To iSuccess
Get ComStringOf Of hoJResp "data.user_id" To sUser_id
Get ComStringOf Of hoJResp "data.email" To sV_Email
Get ComStringOf Of hoJResp "data.names" To sNames
Get ComStringOf Of hoJResp "data.naira_wallet" To sNaira_wallet
Get ComStringOf Of hoJResp "data.providus_account" To sProvidus_account
Get ComStringOf Of hoJResp "data.referral_link" To sReferral_link
End_Procedure
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}"
}
]
}