Foxpro / APPIA API / EDIT USER PROFILE
Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
* 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"
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("address","ado ekiti")
loJson.UpdateString("dob","23-5-2018")
loJson.UpdateString("nnok","adeolu")
loJson.UpdateString("occupation","engineer")
loJson.UpdateString("aonok","balogun street")
loJson.UpdateInt("ponok",234)
loJson.UpdateString("rwnok","son")
loHttp.SetRequestHeader("Content-Type","application/json")
* Adds the "Authorization: Bearer {{auth}}" header.
loHttp.AuthToken = "{{auth}}"
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbRequestBody = CreateObject('Chilkat.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loResp = loHttp.PTextSb("PUT","https://domain.com/profile/",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
CANCEL
ENDIF
? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
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": [
]
}