SQL Server / APPIA API / GET USER DASHBOARD DETAILS
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Adds the "Authorization: Bearer {{auth}}" header.
EXEC sp_OASetProperty @http, 'AuthToken', '{{auth}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://domain.com/users/dashboard_details', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
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
DECLARE @success int
EXEC sp_OAMethod @jResp, 'BoolOf', @success OUT, 'success'
DECLARE @User_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @User_id OUT, 'data.user_id'
DECLARE @v_Email nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Email OUT, 'data.email'
DECLARE @Names nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Names OUT, 'data.names'
DECLARE @Naira_wallet nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Naira_wallet OUT, 'data.naira_wallet'
DECLARE @Providus_account nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Providus_account OUT, 'data.providus_account'
DECLARE @Referral_link nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Referral_link OUT, 'data.referral_link'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
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}"
}
]
}