Chilkat Online Tools

TCL / APPIA API / EDIT USER PROFILE

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

# 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"
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "address" "ado ekiti"
CkJsonObject_UpdateString $json "dob" "23-5-2018"
CkJsonObject_UpdateString $json "nnok" "adeolu"
CkJsonObject_UpdateString $json "occupation" "engineer"
CkJsonObject_UpdateString $json "aonok" "balogun street"
CkJsonObject_UpdateInt $json "ponok" 234
CkJsonObject_UpdateString $json "rwnok" "son"

CkHttp_SetRequestHeader $http "Content-Type" "application/json"
# Adds the "Authorization: Bearer {{auth}}" header.
CkHttp_put_AuthToken $http "{{auth}}"

set sbRequestBody [new_CkStringBuilder]

CkJsonObject_EmitSb $json $sbRequestBody

# resp is a CkHttpResponse
set resp [CkHttp_PTextSb $http "PUT" "https://domain.com/profile/" $sbRequestBody "utf-8" "application/json" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    exit
}

puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp


delete_CkHttp $http
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody

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