Chilkat Online Tools

Objective-C / APPIA API / EDIT USER PROFILE

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <CkoHttpResponse.h>

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

CkoHttp *http = [[CkoHttp alloc] init];
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"
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"address" value: @"ado ekiti"];
[json UpdateString: @"dob" value: @"23-5-2018"];
[json UpdateString: @"nnok" value: @"adeolu"];
[json UpdateString: @"occupation" value: @"engineer"];
[json UpdateString: @"aonok" value: @"balogun street"];
[json UpdateInt: @"ponok" value: [NSNumber numberWithInt: 234]];
[json UpdateString: @"rwnok" value: @"son"];

[http SetRequestHeader: @"Content-Type" value: @"application/json"];
// Adds the "Authorization: Bearer {{auth}}" header.
http.AuthToken = @"{{auth}}";

CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];

CkoHttpResponse *resp = [http PTextSb: @"PUT" url: @"https://domain.com/profile/" textData: sbRequestBody charset: @"utf-8" contentType: @"application/json" md5: NO gzip: NO];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

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": [
  ]
}