Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW 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.
// {
// "agency": {
// "address": {
// "name": "John Smith",
// "street": "1230 Ellen Ave, apt 10",
// "city": "Dallas",
// "stateProvince": "TX",
// "postalCode": "75063",
// "countryCode": "US",
// "freeText": "John Smith\n1230 Ellen Ave, apt 10\nDallas, TX 75063\nUS"
// },
// "agencyCustomerNumber": "1234567",
// "ticketingPolicy": "TODAY"
// },
// "travelers": [
// {
// "givenName": "John",
// "surname": "Smith",
// "birthDate": "1970-01-23",
// "passengerCode": "ADT",
// "ancillaries": [
// {
// "reasonForIssuanceCode": "C",
// "electronicMiscellaneousDocumentType": "FLIGHT_COUPON_ASSOCIATED",
// "reasonForIssuanceName": "BAGGAGE",
// "subcode": "0CC",
// "airlineCode": "LH",
// "groupCode": "BG",
// "basePrice": "35.00",
// "currencyCode": "USD",
// "flightIndices": [
// 1
// ]
// }
// ],
// "specialServices": [
// {
// "code": "FBAG"
// }
// ]
// },
// {
// "givenName": "Mary",
// "surname": "Smith",
// "birthDate": "1970-01-23",
// "passengerCode": "ADT"
// }
// ],
// "contactInfo": {
// "emails": [
// "travel@sabre.com",
// "travel2@sabre.com"
// ],
// "phones": [
// "+123456"
// ]
// },
// "flightDetails": {
// "flights": [
// {
// "flightNumber": 809,
// "airlineCode": "LH",
// "fromAirportCode": "ARN",
// "toAirportCode": "FRA",
// "departureDate": "2021-11-20",
// "departureTime": "06:15",
// "bookingClass": "Y",
// "flightStatusCode": "NN"
// }
// ],
// "flightPricing": [
// {}
// ]
// },
// "payment": {
// "billingAddress": {
// "name": "John Smith",
// "street": "1230 Ellen Ave, apt 10",
// "city": "Dallas",
// "stateProvince": "TX",
// "postalCode": "75063",
// "countryCode": "US"
// }
// }
// }
CkJsonObjectW json;
json.UpdateString(L"agency.address.name",L"John Smith");
json.UpdateString(L"agency.address.street",L"1230 Ellen Ave, apt 10");
json.UpdateString(L"agency.address.city",L"Dallas");
json.UpdateString(L"agency.address.stateProvince",L"TX");
json.UpdateString(L"agency.address.postalCode",L"75063");
json.UpdateString(L"agency.address.countryCode",L"US");
json.UpdateString(L"agency.address.freeText",L"John Smith\n1230 Ellen Ave, apt 10\nDallas, TX 75063\nUS");
json.UpdateString(L"agency.agencyCustomerNumber",L"1234567");
json.UpdateString(L"agency.ticketingPolicy",L"TODAY");
json.UpdateString(L"travelers[0].givenName",L"John");
json.UpdateString(L"travelers[0].surname",L"Smith");
json.UpdateString(L"travelers[0].birthDate",L"1970-01-23");
json.UpdateString(L"travelers[0].passengerCode",L"ADT");
json.UpdateString(L"travelers[0].ancillaries[0].reasonForIssuanceCode",L"C");
json.UpdateString(L"travelers[0].ancillaries[0].electronicMiscellaneousDocumentType",L"FLIGHT_COUPON_ASSOCIATED");
json.UpdateString(L"travelers[0].ancillaries[0].reasonForIssuanceName",L"BAGGAGE");
json.UpdateString(L"travelers[0].ancillaries[0].subcode",L"0CC");
json.UpdateString(L"travelers[0].ancillaries[0].airlineCode",L"LH");
json.UpdateString(L"travelers[0].ancillaries[0].groupCode",L"BG");
json.UpdateString(L"travelers[0].ancillaries[0].basePrice",L"35.00");
json.UpdateString(L"travelers[0].ancillaries[0].currencyCode",L"USD");
json.UpdateInt(L"travelers[0].ancillaries[0].flightIndices[0]",1);
json.UpdateString(L"travelers[0].specialServices[0].code",L"FBAG");
json.UpdateString(L"travelers[1].givenName",L"Mary");
json.UpdateString(L"travelers[1].surname",L"Smith");
json.UpdateString(L"travelers[1].birthDate",L"1970-01-23");
json.UpdateString(L"travelers[1].passengerCode",L"ADT");
json.UpdateString(L"contactInfo.emails[0]",L"travel@sabre.com");
json.UpdateString(L"contactInfo.emails[1]",L"travel2@sabre.com");
json.UpdateString(L"contactInfo.phones[0]",L"+123456");
json.UpdateInt(L"flightDetails.flights[0].flightNumber",809);
json.UpdateString(L"flightDetails.flights[0].airlineCode",L"LH");
json.UpdateString(L"flightDetails.flights[0].fromAirportCode",L"ARN");
json.UpdateString(L"flightDetails.flights[0].toAirportCode",L"FRA");
json.UpdateString(L"flightDetails.flights[0].departureDate",L"2021-11-20");
json.UpdateString(L"flightDetails.flights[0].departureTime",L"06:15");
json.UpdateString(L"flightDetails.flights[0].bookingClass",L"Y");
json.UpdateString(L"flightDetails.flights[0].flightStatusCode",L"NN");
json.UpdateString(L"payment.billingAddress.name",L"John Smith");
json.UpdateString(L"payment.billingAddress.street",L"1230 Ellen Ave, apt 10");
json.UpdateString(L"payment.billingAddress.city",L"Dallas");
json.UpdateString(L"payment.billingAddress.stateProvince",L"TX");
json.UpdateString(L"payment.billingAddress.postalCode",L"75063");
json.UpdateString(L"payment.billingAddress.countryCode",L"US");
http.SetRequestHeader(L"accept",L"application/json");
http.SetRequestHeader(L"Content-Type",L"application/json");
http.SetRequestHeader(L"X-Sabre-Group",L"G7RE");
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken(L"<access_token>");
http.SetRequestHeader(L"X-Sabre-Current-City",L"G7RE");
CkHttpResponseW *resp = http.PostJson3(L"https://domain.com/",L"application/json",json);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"%d\n",resp->get_StatusCode());
wprintf(L"%s\n",resp->bodyStr());
delete resp;
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "accept: application/json"
-H "Content-Type: application/json"
-H "X-Sabre-Group: G7RE"
-H "X-Sabre-Current-City: G7RE"
-d '{
"agency": {
"address": {
"name": "John Smith",
"street": "1230 Ellen Ave, apt 10",
"city": "Dallas",
"stateProvince": "TX",
"postalCode": "75063",
"countryCode": "US",
"freeText": "John Smith\n1230 Ellen Ave, apt 10\nDallas, TX 75063\nUS"
},
"agencyCustomerNumber": "1234567",
"ticketingPolicy": "TODAY"
},
"travelers": [
{
"givenName": "John",
"surname": "Smith",
"birthDate": "1970-01-23",
"passengerCode": "ADT",
"ancillaries": [
{
"reasonForIssuanceCode": "C",
"electronicMiscellaneousDocumentType": "FLIGHT_COUPON_ASSOCIATED",
"reasonForIssuanceName": "BAGGAGE",
"subcode": "0CC",
"airlineCode": "LH",
"groupCode": "BG",
"basePrice": "35.00",
"currencyCode": "USD",
"flightIndices": [
1
]
}
],
"specialServices": [
{
"code": "FBAG"
}
]
},
{
"givenName": "Mary",
"surname": "Smith",
"birthDate": "1970-01-23",
"passengerCode": "ADT"
}
],
"contactInfo": {
"emails": [
"travel@sabre.com",
"travel2@sabre.com"
],
"phones": [
"+123456"
]
},
"flightDetails": {
"flights": [
{
"flightNumber": 809,
"airlineCode": "LH",
"fromAirportCode": "ARN",
"toAirportCode": "FRA",
"departureDate": "2021-11-20",
"departureTime": "06:15",
"bookingClass": "Y",
"flightStatusCode": "NN"
}
],
"flightPricing": [
{}
]
},
"payment": {
"billingAddress": {
"name": "John Smith",
"street": "1230 Ellen Ave, apt 10",
"city": "Dallas",
"stateProvince": "TX",
"postalCode": "75063",
"countryCode": "US"
}
}
}'
https://domain.com/
Postman Collection Item JSON
{
"name": "createBooking - Ancillaries baggage with SSR",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"response is ok\", function () {\r",
" pm.response.to.be.ok;\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"pm.test(\"response must be valid and have a body\", function () {\r",
" // this assertion also checks if a body exists\r",
" pm.response.to.be.json; \r",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "accept",
"type": "text",
"value": "application/json"
},
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "X-Sabre-Group",
"value": "G7RE",
"type": "text"
},
{
"key": "X-Sabre-Current-City",
"value": "G7RE",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"agency\": {\n \"address\": {\n \"name\": \"John Smith\",\n \"street\": \"1230 Ellen Ave, apt 10\",\n \"city\": \"Dallas\",\n \"stateProvince\": \"TX\",\n \"postalCode\": \"75063\",\n \"countryCode\": \"US\",\n \"freeText\": \"John Smith\\n1230 Ellen Ave, apt 10\\nDallas, TX 75063\\nUS\"\n },\n \"agencyCustomerNumber\": \"1234567\",\n \"ticketingPolicy\": \"TODAY\"\n },\n \"travelers\": [\n {\n \"givenName\": \"John\",\n \"surname\": \"Smith\",\n \"birthDate\": \"1970-01-23\",\n \"passengerCode\": \"ADT\",\n \"ancillaries\": [\n {\n \"reasonForIssuanceCode\": \"C\",\n \"electronicMiscellaneousDocumentType\": \"FLIGHT_COUPON_ASSOCIATED\",\n \"reasonForIssuanceName\": \"BAGGAGE\",\n \"subcode\": \"0CC\",\n \"airlineCode\": \"LH\",\n \"groupCode\": \"BG\",\n \"basePrice\": \"35.00\",\n \"currencyCode\": \"USD\",\n \"flightIndices\": [\n 1\n ]\n }\n ],\n \"specialServices\": [\n {\n \"code\": \"FBAG\"\n }\n ]\n },\n {\n \"givenName\": \"Mary\",\n \"surname\": \"Smith\",\n \"birthDate\": \"1970-01-23\",\n \"passengerCode\": \"ADT\"\n }\n ],\n \"contactInfo\": {\n \"emails\": [\n \"travel@sabre.com\",\n \"travel2@sabre.com\"\n ],\n \"phones\": [\n \"+123456\"\n ]\n },\n \"flightDetails\": {\n \"flights\": [\n {\n \"flightNumber\": 809,\n \"airlineCode\": \"LH\",\n \"fromAirportCode\": \"ARN\",\n \"toAirportCode\": \"FRA\",\n \"departureDate\": \"2021-11-20\",\n \"departureTime\": \"06:15\",\n \"bookingClass\": \"Y\",\n \"flightStatusCode\": \"NN\"\n }\n ],\n \"flightPricing\": [\n {}\n ]\n },\n \"payment\": {\n \"billingAddress\": {\n \"name\": \"John Smith\",\n \"street\": \"1230 Ellen Ave, apt 10\",\n \"city\": \"Dallas\",\n \"stateProvince\": \"TX\",\n \"postalCode\": \"75063\",\n \"countryCode\": \"US\"\n }\n }\n}"
},
"url": {
"raw": "{{createBooking_endpoint}}",
"host": [
"{{createBooking_endpoint}}"
]
},
"description": "### <br>"
},
"response": [
]
}