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.
// {
// "criteria": {
// "hotelId": "{{HotelId}}",
// "arrivalDate": "2021-04-06",
// "nights": 1,
// "adults": 1,
// "children": 0,
// "numberOfRooms": 1,
// "roomType": "STDD",
// "rateCode": "RACK"
// }
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"criteria.hotelId" value: @"{{HotelId}}"];
[json UpdateString: @"criteria.arrivalDate" value: @"2021-04-06"];
[json UpdateInt: @"criteria.nights" value: [NSNumber numberWithInt: 1]];
[json UpdateInt: @"criteria.adults" value: [NSNumber numberWithInt: 1]];
[json UpdateInt: @"criteria.children" value: [NSNumber numberWithInt: 0]];
[json UpdateInt: @"criteria.numberOfRooms" value: [NSNumber numberWithInt: 1]];
[json UpdateString: @"criteria.roomType" value: @"STDD"];
[json UpdateString: @"criteria.rateCode" value: @"RACK"];
[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/rsv/config/v0/hotels/{{HotelId}}/upsellRules/action/validate" 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-app-key: {{AppKey}}"
-H "x-hotelid: {{HotelId}}"
-d '{
"criteria": {
"hotelId": "{{HotelId}}",
"arrivalDate": "2021-04-06",
"nights": 1,
"adults": 1,
"children": 0,
"numberOfRooms": 1,
"roomType": "STDD",
"rateCode": "RACK"
}
}'
https://domain.com/rsv/config/v0/hotels/{{HotelId}}/upsellRules/action/validate
Postman Collection Item JSON
{
"name": "Test an upsell Rule",
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "x-app-key",
"type": "text",
"value": "{{AppKey}}"
},
{
"key": "x-hotelid",
"type": "text",
"value": "{{HotelId}}"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"criteria\": {\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"arrivalDate\": \"2021-04-06\",\r\n \"nights\": 1,\r\n \"adults\": 1,\r\n \"children\": 0,\r\n \"numberOfRooms\": 1,\r\n \"roomType\": \"STDD\",\r\n \"rateCode\": \"RACK\"\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HostName}}/rsv/config/v0/hotels/{{HotelId}}/upsellRules/action/validate",
"host": [
"{{HostName}}"
],
"path": [
"rsv",
"config",
"v0",
"hotels",
"{{HotelId}}",
"upsellRules",
"action",
"validate"
]
}
},
"response": [
]
}