ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/json
explicitContentType: application/json
---- begin chilkat script ----
// This example assumes the Chilkat API to have been previously unlocked.
// See {{-global_unlock:::Global Unlock Sample-}} for sample code.
new Http http;
ckbool success;
// Use this online tool to generate code from sample JSON: {{.https://tools.chilkat.io/jsonCreate|||Generate Code to Create JSON.}}
// The following JSON is sent in the request body.
// {
// "reservations": [
// {
// "reservationIdList": [
// {
// "type": "Reservation",
// "id": "{{ReservationId}}"
// }
// ],
// "roomStay": {
// "arrivalDate": "2021-03-23",
// "departureDate": "2021-03-23",
// "expectedTimes": {
// "reservationExpectedArrivalTime": "2021-03-23 13:00:00.0",
// "reservationExpectedDepartureTime": "2021-03-23 10:00:00.0"
// }
// },
// "hotelId": "{{HotelId}}",
// "customReference": "",
// "preRegistered": false,
// "allowMobileCheckout": false
// }
// ]
// }
new JsonObject json;
ignore = json.UpdateString("reservations[0].reservationIdList[0].type","Reservation");
ignore = json.UpdateString("reservations[0].reservationIdList[0].id","{{ReservationId}}");
ignore = json.UpdateString("reservations[0].roomStay.arrivalDate","2021-03-23");
ignore = json.UpdateString("reservations[0].roomStay.departureDate","2021-03-23");
ignore = json.UpdateString("reservations[0].roomStay.expectedTimes.reservationExpectedArrivalTime","2021-03-23 13:00:00.0");
ignore = json.UpdateString("reservations[0].roomStay.expectedTimes.reservationExpectedDepartureTime","2021-03-23 10:00:00.0");
ignore = json.UpdateString("reservations[0].hotelId","{{HotelId}}");
ignore = json.UpdateString("reservations[0].customReference","");
ignore = json.UpdateBool("reservations[0].preRegistered",ckfalse);
ignore = json.UpdateBool("reservations[0].allowMobileCheckout",ckfalse);
call http.SetRequestHeader("Content-Type","application/json");
call http.SetRequestHeader("x-hotelid","{{HotelId}}");
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>";
call http.SetRequestHeader("x-app-key","{{AppKey}}");
new StringBuilder sbRequestBody;
call json.EmitSb(sbRequestBody);
HttpResponse resp = http.PTextSb("PUT","https://domain.com/rsv/v1/hotels/{{HotelId}}/reservations/{{ReservationId}}",sbRequestBody,"utf-8","application/json",ckfalse,ckfalse);
if (http.LastMethodSuccess == ckfalse) {
println http.LastErrorText;
return;
}
println resp.StatusCode;
println resp.BodyStr;
delete resp;
---- end chilkat script ----
Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Chilkat.Http http = new Chilkat.Http();
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.
// {
// "reservations": [
// {
// "reservationIdList": [
// {
// "type": "Reservation",
// "id": "{{ReservationId}}"
// }
// ],
// "roomStay": {
// "arrivalDate": "2021-03-23",
// "departureDate": "2021-03-23",
// "expectedTimes": {
// "reservationExpectedArrivalTime": "2021-03-23 13:00:00.0",
// "reservationExpectedDepartureTime": "2021-03-23 10:00:00.0"
// }
// },
// "hotelId": "{{HotelId}}",
// "customReference": "",
// "preRegistered": false,
// "allowMobileCheckout": false
// }
// ]
// }
Chilkat.JsonObject json = new Chilkat.JsonObject();
json.UpdateString("reservations[0].reservationIdList[0].type","Reservation");
json.UpdateString("reservations[0].reservationIdList[0].id","{{ReservationId}}");
json.UpdateString("reservations[0].roomStay.arrivalDate","2021-03-23");
json.UpdateString("reservations[0].roomStay.departureDate","2021-03-23");
json.UpdateString("reservations[0].roomStay.expectedTimes.reservationExpectedArrivalTime","2021-03-23 13:00:00.0");
json.UpdateString("reservations[0].roomStay.expectedTimes.reservationExpectedDepartureTime","2021-03-23 10:00:00.0");
json.UpdateString("reservations[0].hotelId","{{HotelId}}");
json.UpdateString("reservations[0].customReference","");
json.UpdateBool("reservations[0].preRegistered",false);
json.UpdateBool("reservations[0].allowMobileCheckout",false);
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
// Adds the "Authorization: Bearer <access_token>" header.
ERROR: Property not found: Http.AuthToken
Assignment type mismatch. ExpressionType=string, atgType=ERROR:
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
Chilkat.StringBuilder sbRequestBody = new Chilkat.StringBuilder();
json.EmitSb(sbRequestBody);
ERROR: Entry not found: Http.PTextSb
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
--emitNewObject
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
--emitNewObject
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
--CodeGen
ERROR: Non-existent Chilkat method: Http.PTextSb
Chilkat.HttpResponse resp = http.PTextSb("PUT","https://domain.com/rsv/v1/hotels/{{HotelId}}/reservations/{{ReservationId}}",sbRequestBody,"utf-8","application/json",false,false);
ERROR: Entry not found: Http.LastMethodSuccess
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
--emitNewObject
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
--emitNewObject
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
--CodeGen
if (ERROR: Property not found: Http.LastMethodSuccess
== false) {
ERROR: Entry not found: Http.LastErrorText
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
--emitNewObject
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
--emitNewObject
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
--CodeGen
Debug.WriteLine(Convert.ToString(ERROR: Property not found: Http.LastErrorText
));
return;
}
Debug.WriteLine(Convert.ToString(resp.StatusCode));
Debug.WriteLine(resp.BodyStr);
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-H "x-hotelid: {{HotelId}}"
-H "x-app-key: {{AppKey}}"
-d '{
"reservations": [
{
"reservationIdList": [
{
"type": "Reservation",
"id": "{{ReservationId}}"
}
],
"roomStay": {
"arrivalDate": "2021-03-23",
"departureDate": "2021-03-23",
"expectedTimes": {
"reservationExpectedArrivalTime": "2021-03-23 13:00:00.0",
"reservationExpectedDepartureTime": "2021-03-23 10:00:00.0"
}
},
"hotelId": "{{HotelId}}",
"customReference": "",
"preRegistered": false,
"allowMobileCheckout": false
}
]
}'
https://domain.com/rsv/v1/hotels/{{HotelId}}/reservations/{{ReservationId}}
Postman Collection Item JSON
{
"name": "14. Check-Out - putReservation (add departure time)",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "x-hotelid",
"value": "{{HotelId}}",
"type": "text"
},
{
"key": "x-app-key",
"value": "{{AppKey}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"reservations\": [\r\n {\r\n \"reservationIdList\": [\r\n {\r\n \"type\": \"Reservation\",\r\n \"id\": \"{{ReservationId}}\"\r\n }\r\n ],\r\n \"roomStay\": {\r\n \"arrivalDate\": \"2021-03-23\",\r\n \"departureDate\": \"2021-03-23\",\r\n \"expectedTimes\": {\r\n \"reservationExpectedArrivalTime\": \"2021-03-23 13:00:00.0\",\r\n \"reservationExpectedDepartureTime\": \"2021-03-23 10:00:00.0\"\r\n }\r\n },\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"customReference\": \"\",\r\n \"preRegistered\": false,\r\n \"allowMobileCheckout\": false\r\n }\r\n ]\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HostName}}/rsv/v1/hotels/{{HotelId}}/reservations/{{ReservationId}}",
"host": [
"{{HostName}}"
],
"path": [
"rsv",
"v1",
"hotels",
"{{HotelId}}",
"reservations",
"{{ReservationId}}"
]
},
"description": "A reservation must have $0 balance, and be in 'Due-out' status to be able to check out."
},
"response": [
]
}