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.
// {
// "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
// }
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateBool: @"verificationOnly" value: NO];
[json UpdateString: @"changeBlockStatus.hotelId" value: @"{{HotelId}}"];
[json UpdateString: @"changeBlockStatus.blockId.type" value: @"Block"];
[json UpdateString: @"changeBlockStatus.blockId.idContext" value: @"OPERA"];
[json UpdateString: @"changeBlockStatus.blockId.id" value: @"{{BlockId}}"];
[json UpdateString: @"changeBlockStatus.currentBlockStatus" value: @"TEN"];
[json UpdateString: @"changeBlockStatus.newBlockStatus" value: @"DEF"];
[json UpdateString: @"changeBlockStatus.reservationType" value: @"GRPGTD"];
[json UpdateBool: @"changeBlockStatus.overbookAll" value: YES];
[json UpdateBool: @"changeBlockStatus.cancelAllPMReservations" value: NO];
[json UpdateBool: @"changeBlockStatus.applyChangesToCateringSatus" value: NO];
[json UpdateBool: @"changeBlockStatus.overrideEventsProcessingWarnings" value: YES];
[http SetRequestHeader: @"x-app-key" value: @"{{AppKey}}"];
[http SetRequestHeader: @"x-hotelid" value: @"{{HotelId}}"];
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = @"<access_token>";
CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoHttpResponse *resp = [http PTextSb: @"PUT" url: @"https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/status" 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 "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": [
]
}