Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_Resp
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "profileDetails": {
// "addresses": {
// "addressInfo": [
// {
// "address": {
// "addressLine": [
// "2640 Golden Gate Parkway",
// "Suite 300",
// "",
// ""
// ],
// "cityName": "Naples",
// "postalCode": "34105",
// "state": "FL",
// "language": "E",
// "type": "HOME",
// "typeDescription": "Home Address",
// "primaryInd": true
// }
// }
// ]
// },
// "telephones": {
// "telephoneInfo": [
// {
// "telephone": {
// "phoneTechType": "PHONE",
// "phoneUseType": "MOBILE",
// "phoneUseTypeDescription": "Mobile Phone Number",
// "phoneNumber": "+1 415 555 0101",
// "primaryInd": true,
// "orderSequence": "1"
// }
// }
// ]
// },
// "statusCode": "ACTIVE",
// "markForHistory": false,
// "hasCommission": false
// }
// }
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.addressLine[0]","2640 Golden Gate Parkway")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.addressLine[1]","Suite 300")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.addressLine[2]","")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.addressLine[3]","")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.cityName","Naples")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.postalCode","34105")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.state","FL")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.language","E")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.type","HOME")
loo_Json.UpdateString("profileDetails.addresses.addressInfo[0].address.typeDescription","Home Address")
loo_Json.UpdateBool("profileDetails.addresses.addressInfo[0].address.primaryInd",1)
loo_Json.UpdateString("profileDetails.telephones.telephoneInfo[0].telephone.phoneTechType","PHONE")
loo_Json.UpdateString("profileDetails.telephones.telephoneInfo[0].telephone.phoneUseType","MOBILE")
loo_Json.UpdateString("profileDetails.telephones.telephoneInfo[0].telephone.phoneUseTypeDescription","Mobile Phone Number")
loo_Json.UpdateString("profileDetails.telephones.telephoneInfo[0].telephone.phoneNumber","+1 415 555 0101")
loo_Json.UpdateBool("profileDetails.telephones.telephoneInfo[0].telephone.primaryInd",1)
loo_Json.UpdateString("profileDetails.telephones.telephoneInfo[0].telephone.orderSequence","1")
loo_Json.UpdateString("profileDetails.statusCode","ACTIVE")
loo_Json.UpdateBool("profileDetails.markForHistory",0)
loo_Json.UpdateBool("profileDetails.hasCommission",0)
loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Http.SetRequestHeader("x-app-key","{{AppKey}}")
loo_Http.SetRequestHeader("x-hotelid","{{HotelId}}")
// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"
loo_SbRequestBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Json.EmitSb(loo_SbRequestBody)
loo_Resp = loo_Http.PTextSb("PUT","https://domain.com/crm/v1/profiles/{{ProfileId}}",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
return
end if
Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-H "x-app-key: {{AppKey}}"
-H "x-hotelid: {{HotelId}}"
-d '{
"profileDetails": {
"addresses": {
"addressInfo": [
{
"address": {
"addressLine": [
"2640 Golden Gate Parkway",
"Suite 300",
"",
""
],
"cityName": "Naples",
"postalCode": "34105",
"state": "FL",
"language": "E",
"type": "HOME",
"typeDescription": "Home Address",
"primaryInd": true
}
}
]
},
"telephones": {
"telephoneInfo": [
{
"telephone": {
"phoneTechType": "PHONE",
"phoneUseType": "MOBILE",
"phoneUseTypeDescription": "Mobile Phone Number",
"phoneNumber": "+1 415 555 0101",
"primaryInd": true,
"orderSequence": "1"
}
}
]
},
"statusCode": "ACTIVE",
"markForHistory": false,
"hasCommission": false
}
}'
https://domain.com/crm/v1/profiles/{{ProfileId}}
Postman Collection Item JSON
{
"name": "Update the guest profile with new contact details",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "x-app-key",
"value": "{{AppKey}}",
"type": "text"
},
{
"key": "x-hotelid",
"value": "{{HotelId}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"profileDetails\": {\n \"addresses\": {\n \"addressInfo\": [\n {\n \"address\": {\n \"addressLine\": [\n \"2640 Golden Gate Parkway\",\n \"Suite 300\",\n \"\",\n \"\"\n ],\n \"cityName\": \"Naples\",\n \"postalCode\": \"34105\",\n \"state\": \"FL\",\n \"language\": \"E\",\n \"type\": \"HOME\",\n \"typeDescription\": \"Home Address\",\n \"primaryInd\": true\n }\n }\n ]\n },\n \"telephones\": {\n \"telephoneInfo\": [\n {\n \"telephone\": {\n \"phoneTechType\": \"PHONE\",\n \"phoneUseType\": \"MOBILE\",\n \"phoneUseTypeDescription\": \"Mobile Phone Number\",\n \"phoneNumber\": \"+1 415 555 0101\",\n \"primaryInd\": true,\n \"orderSequence\": \"1\"\n }\n }\n ]\n },\n \"statusCode\": \"ACTIVE\",\n \"markForHistory\": false,\n \"hasCommission\": false\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HostName}}/crm/v1/profiles/{{ProfileId}}",
"host": [
"{{HostName}}"
],
"path": [
"crm",
"v1",
"profiles",
"{{ProfileId}}"
]
}
},
"response": [
]
}