unicodeC / APPIA API / ADD USER PROFILE
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "address": "address",
// "occupation": "jbh",
// "dob": "dob",
// "nnok": "nnok",
// "aonok": "aonok",
// "ponok": 2345646,
// "rwnok": "rwnok"
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"address",L"address");
CkJsonObjectW_UpdateString(json,L"occupation",L"jbh");
CkJsonObjectW_UpdateString(json,L"dob",L"dob");
CkJsonObjectW_UpdateString(json,L"nnok",L"nnok");
CkJsonObjectW_UpdateString(json,L"aonok",L"aonok");
CkJsonObjectW_UpdateInt(json,L"ponok",2345646);
CkJsonObjectW_UpdateString(json,L"rwnok",L"rwnok");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
// Adds the "Authorization: Bearer {{auth}}" header.
CkHttpW_putAuthToken(http,L"{{auth}}");
resp = CkHttpW_PostJson3(http,L"https://domain.com/profile/add_profile",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer {{auth}}"
-d '{
"address" : "address",
"occupation":"jbh",
"dob" : "dob",
"nnok" : "nnok",
"aonok" : "aonok",
"ponok" : 2345646,
"rwnok" : "rwnok"
}'
https://domain.com/profile/add_profile
Postman Collection Item JSON
{
"name": "ADD USER PROFILE",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{auth}}"
}
],
"body": {
"mode": "raw",
"raw": " \t\t\t{\r\n \"address\" : \"address\",\r\n \"occupation\":\"jbh\",\r\n \"dob\" : \"dob\",\r\n \"nnok\" : \"nnok\",\r\n \"aonok\" : \"aonok\",\r\n \"ponok\" : 2345646,\r\n \"rwnok\" : \"rwnok\"\r\n \t\t\t}"
},
"url": {
"raw": "{{url}}/profile/add_profile",
"host": [
"{{url}}"
],
"path": [
"profile",
"add_profile"
]
},
"description": "User profile update"
},
"response": [
]
}