Chilkat Online Tools

unicodeCpp / APPIA API / EDIT USER PROFILE

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>

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

    CkHttpW http;
    bool success;

    // 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": "ado ekiti",
    //   "dob": "23-5-2018",
    //   "nnok": "adeolu",
    //   "occupation": "engineer",
    //   "aonok": "balogun street",
    //   "ponok": 234,
    //   "rwnok": "son"
    // }

    CkJsonObjectW json;
    json.UpdateString(L"address",L"ado ekiti");
    json.UpdateString(L"dob",L"23-5-2018");
    json.UpdateString(L"nnok",L"adeolu");
    json.UpdateString(L"occupation",L"engineer");
    json.UpdateString(L"aonok",L"balogun street");
    json.UpdateInt(L"ponok",234);
    json.UpdateString(L"rwnok",L"son");

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

    CkStringBuilderW sbRequestBody;
    json.EmitSb(sbRequestBody);

    CkHttpResponseW *resp = http.PTextSb(L"PUT",L"https://domain.com/profile/",sbRequestBody,L"utf-8",L"application/json",false,false);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%d\n",resp->get_StatusCode());
    wprintf(L"%s\n",resp->bodyStr());
    delete resp;
    }

Curl Command

curl -X PUT
	-H "Content-Type: application/json"
	-H "Authorization: Bearer {{auth}}"
	-d '{
                 "address" : "ado ekiti",
                 "dob" : "23-5-2018",
                 "nnok" : "adeolu",
                 "occupation":"engineer",
                 "aonok" : "balogun street",
                 "ponok" : 234,
                 "rwnok" : "son"
    			}'
https://domain.com/profile/

Postman Collection Item JSON

{
  "name": "EDIT USER PROFILE",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "value": "Bearer {{auth}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "    \t\t\t{\r\n                 \"address\" : \"ado ekiti\",\r\n                 \"dob\" : \"23-5-2018\",\r\n                 \"nnok\" : \"adeolu\",\r\n                 \"occupation\":\"engineer\",\r\n                 \"aonok\" : \"balogun street\",\r\n                 \"ponok\" : 234,\r\n                 \"rwnok\" : \"son\"\r\n    \t\t\t}"
    },
    "url": {
      "raw": "{{url}}/profile/",
      "host": [
        "{{url}}"
      ],
      "path": [
        "profile",
        ""
      ]
    },
    "description": "User profile update"
  },
  "response": [
  ]
}