Back to Collection Items
var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
sbRequestBody: HCkStringBuilder;
resp: HCkHttpResponse;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "verificationOnly": false,
// "changeBlockStatus": {
// "hotelId": "{{HotelId}}",
// "blockId": {
// "type": "Block",
// "idContext": "OPERA",
// "id": "{{BlockId}}"
// },
// "currentBlockStatus": "TEN",
// "newBlockStatus": "DEF",
// "reservationType": "GRPGTD",
// "overbookAll": true,
// "cancelAllPMReservations": false,
// "applyChangesToCateringSatus": false,
// "overrideEventsProcessingWarnings": true
// }
// }
json := CkJsonObject_Create();
CkJsonObject_UpdateBool(json,'verificationOnly',False);
CkJsonObject_UpdateString(json,'changeBlockStatus.hotelId','{{HotelId}}');
CkJsonObject_UpdateString(json,'changeBlockStatus.blockId.type','Block');
CkJsonObject_UpdateString(json,'changeBlockStatus.blockId.idContext','OPERA');
CkJsonObject_UpdateString(json,'changeBlockStatus.blockId.id','{{BlockId}}');
CkJsonObject_UpdateString(json,'changeBlockStatus.currentBlockStatus','TEN');
CkJsonObject_UpdateString(json,'changeBlockStatus.newBlockStatus','DEF');
CkJsonObject_UpdateString(json,'changeBlockStatus.reservationType','GRPGTD');
CkJsonObject_UpdateBool(json,'changeBlockStatus.overbookAll',True);
CkJsonObject_UpdateBool(json,'changeBlockStatus.cancelAllPMReservations',False);
CkJsonObject_UpdateBool(json,'changeBlockStatus.applyChangesToCateringSatus',False);
CkJsonObject_UpdateBool(json,'changeBlockStatus.overrideEventsProcessingWarnings',True);
CkHttp_SetRequestHeader(http,'x-app-key','{{AppKey}}');
CkHttp_SetRequestHeader(http,'x-hotelid','{{HotelId}}');
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,'<access_token>');
sbRequestBody := CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
resp := CkHttp_PTextSb(http,'PUT','https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/status',sbRequestBody,'utf-8','application/json',False,False);
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "x-hotelid: {{HotelId}}"
-H "x-app-key: {{AppKey}}"
-d '{
"verificationOnly": false,
"changeBlockStatus": {
"hotelId": "{{HotelId}}",
"blockId": {
"type": "Block",
"idContext": "OPERA",
"id": "{{BlockId}}"
},
"currentBlockStatus": "TEN",
"newBlockStatus": "DEF",
"reservationType": "GRPGTD",
"overbookAll": true,
"cancelAllPMReservations": false,
"applyChangesToCateringSatus": false,
"overrideEventsProcessingWarnings": true
}
}'
https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/status
Postman Collection Item JSON
{
"name": "Update the Block's Status",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "x-hotelid",
"value": "{{HotelId}}"
},
{
"key": "x-app-key",
"value": "{{AppKey}}"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"verificationOnly\": false,\r\n \"changeBlockStatus\": {\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"blockId\": {\r\n \"type\": \"Block\",\r\n \"idContext\": \"OPERA\",\r\n \"id\": \"{{BlockId}}\"\r\n },\r\n \"currentBlockStatus\": \"TEN\",\r\n \"newBlockStatus\": \"DEF\",\r\n \"reservationType\": \"GRPGTD\",\r\n \"overbookAll\": true,\r\n \"cancelAllPMReservations\": false,\r\n \"applyChangesToCateringSatus\": false,\r\n \"overrideEventsProcessingWarnings\": true\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HostName}}/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/status",
"host": [
"{{HostName}}"
],
"path": [
"blk",
"v0",
"hotels",
"{{HotelId}}",
"blocks",
"{{BlockId}}",
"status"
]
},
"description": "\"overbookAll\": true/ false. Set this to false, to ensure relevant warnings are returned about changing the status. Set to true, to override all warnings."
},
"response": [
]
}