Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_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.
// {
// "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": [
// {
// "reasonForIssuance": "BAGGAGE",
// "subcode": "0C2",
// "airlineCode": "EY",
// "electronicMiscellaneousDocumentType": "FLIGHT_COUPON_ASSOCIATED",
// "basePrice": "528.00",
// "currencyCode": "USD",
// "groupCode": "BG",
// "flightIndices": [
// 1
// ]
// },
// {
// "reasonForIssuance": "BAGGAGE",
// "subcode": "0C4",
// "airlineCode": "EY",
// "electronicMiscellaneousDocumentType": "FLIGHT_COUPON_ASSOCIATED",
// "basePrice": "656.00",
// "currencyCode": "USD",
// "groupCode": "BG",
// "flightIndices": [
// 1
// ]
// }
// ]
// },
// {
// "givenName": "Mary",
// "surname": "Smith",
// "birthDate": "1970-01-23",
// "passengerCode": "ADT"
// }
// ],
// "contactInfo": {
// "emails": [
// "travel@sabre.com",
// "travel2@sabre.com"
// ],
// "phones": [
// "+123456"
// ]
// },
// "flightDetails": {
// "flights": [
// {
// "flightNumber": 78,
// "airlineCode": "EY",
// "fromAirportCode": "AMS",
// "toAirportCode": "AUH",
// "departureDate": "2021-11-19",
// "departureTime": "20:25",
// "bookingClass": "V",
// "flightStatusCode": "NN"
// },
// {
// "flightNumber": 77,
// "airlineCode": "EY",
// "fromAirportCode": "AUH",
// "toAirportCode": "AMS",
// "departureDate": "2021-11-26",
// "departureTime": "09:00",
// "bookingClass": "V",
// "flightStatusCode": "NN"
// }
// ],
// "flightPricing": [
// {}
// ]
// },
// "payment": {
// "billingAddress": {
// "name": "John Smith",
// "street": "1230 Ellen Ave, apt 10",
// "city": "Dallas",
// "stateProvince": "TX",
// "postalCode": "75063",
// "countryCode": "US"
// }
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"agency.address.name",L"John Smith");
CkJsonObjectW_UpdateString(json,L"agency.address.street",L"1230 Ellen Ave, apt 10");
CkJsonObjectW_UpdateString(json,L"agency.address.city",L"Dallas");
CkJsonObjectW_UpdateString(json,L"agency.address.stateProvince",L"TX");
CkJsonObjectW_UpdateString(json,L"agency.address.postalCode",L"75063");
CkJsonObjectW_UpdateString(json,L"agency.address.countryCode",L"US");
CkJsonObjectW_UpdateString(json,L"agency.address.freeText",L"John Smith\n1230 Ellen Ave, apt 10\nDallas, TX 75063\nUS");
CkJsonObjectW_UpdateString(json,L"agency.agencyCustomerNumber",L"1234567");
CkJsonObjectW_UpdateString(json,L"agency.ticketingPolicy",L"TODAY");
CkJsonObjectW_UpdateString(json,L"travelers[0].givenName",L"John");
CkJsonObjectW_UpdateString(json,L"travelers[0].surname",L"Smith");
CkJsonObjectW_UpdateString(json,L"travelers[0].birthDate",L"1970-01-23");
CkJsonObjectW_UpdateString(json,L"travelers[0].passengerCode",L"ADT");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[0].reasonForIssuance",L"BAGGAGE");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[0].subcode",L"0C2");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[0].airlineCode",L"EY");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[0].electronicMiscellaneousDocumentType",L"FLIGHT_COUPON_ASSOCIATED");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[0].basePrice",L"528.00");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[0].currencyCode",L"USD");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[0].groupCode",L"BG");
CkJsonObjectW_UpdateInt(json,L"travelers[0].ancillaries[0].flightIndices[0]",1);
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[1].reasonForIssuance",L"BAGGAGE");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[1].subcode",L"0C4");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[1].airlineCode",L"EY");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[1].electronicMiscellaneousDocumentType",L"FLIGHT_COUPON_ASSOCIATED");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[1].basePrice",L"656.00");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[1].currencyCode",L"USD");
CkJsonObjectW_UpdateString(json,L"travelers[0].ancillaries[1].groupCode",L"BG");
CkJsonObjectW_UpdateInt(json,L"travelers[0].ancillaries[1].flightIndices[0]",1);
CkJsonObjectW_UpdateString(json,L"travelers[1].givenName",L"Mary");
CkJsonObjectW_UpdateString(json,L"travelers[1].surname",L"Smith");
CkJsonObjectW_UpdateString(json,L"travelers[1].birthDate",L"1970-01-23");
CkJsonObjectW_UpdateString(json,L"travelers[1].passengerCode",L"ADT");
CkJsonObjectW_UpdateString(json,L"contactInfo.emails[0]",L"travel@sabre.com");
CkJsonObjectW_UpdateString(json,L"contactInfo.emails[1]",L"travel2@sabre.com");
CkJsonObjectW_UpdateString(json,L"contactInfo.phones[0]",L"+123456");
CkJsonObjectW_UpdateInt(json,L"flightDetails.flights[0].flightNumber",78);
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[0].airlineCode",L"EY");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[0].fromAirportCode",L"AMS");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[0].toAirportCode",L"AUH");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[0].departureDate",L"2021-11-19");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[0].departureTime",L"20:25");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[0].bookingClass",L"V");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[0].flightStatusCode",L"NN");
CkJsonObjectW_UpdateInt(json,L"flightDetails.flights[1].flightNumber",77);
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[1].airlineCode",L"EY");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[1].fromAirportCode",L"AUH");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[1].toAirportCode",L"AMS");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[1].departureDate",L"2021-11-26");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[1].departureTime",L"09:00");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[1].bookingClass",L"V");
CkJsonObjectW_UpdateString(json,L"flightDetails.flights[1].flightStatusCode",L"NN");
CkJsonObjectW_UpdateString(json,L"payment.billingAddress.name",L"John Smith");
CkJsonObjectW_UpdateString(json,L"payment.billingAddress.street",L"1230 Ellen Ave, apt 10");
CkJsonObjectW_UpdateString(json,L"payment.billingAddress.city",L"Dallas");
CkJsonObjectW_UpdateString(json,L"payment.billingAddress.stateProvince",L"TX");
CkJsonObjectW_UpdateString(json,L"payment.billingAddress.postalCode",L"75063");
CkJsonObjectW_UpdateString(json,L"payment.billingAddress.countryCode",L"US");
CkHttpW_SetRequestHeader(http,L"accept",L"application/json");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
CkHttpW_SetRequestHeader(http,L"X-Sabre-Group",L"G7RE");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
CkHttpW_SetRequestHeader(http,L"X-Sabre-Current-City",L"G7RE");
resp = CkHttpW_PostJson3(http,L"https://domain.com/",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
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": [
{
"reasonForIssuance": "BAGGAGE",
"subcode": "0C2",
"airlineCode": "EY",
"electronicMiscellaneousDocumentType": "FLIGHT_COUPON_ASSOCIATED",
"basePrice": "528.00",
"currencyCode": "USD",
"groupCode": "BG",
"flightIndices": [
1
]
},
{
"reasonForIssuance": "BAGGAGE",
"subcode": "0C4",
"airlineCode": "EY",
"electronicMiscellaneousDocumentType": "FLIGHT_COUPON_ASSOCIATED",
"basePrice": "656.00",
"currencyCode": "USD",
"groupCode": "BG",
"flightIndices": [
1
]
}
]
},
{
"givenName": "Mary",
"surname": "Smith",
"birthDate": "1970-01-23",
"passengerCode": "ADT"
}
],
"contactInfo": {
"emails": [
"travel@sabre.com",
"travel2@sabre.com"
],
"phones": [
"+123456"
]
},
"flightDetails": {
"flights": [
{
"flightNumber": 78,
"airlineCode": "EY",
"fromAirportCode": "AMS",
"toAirportCode": "AUH",
"departureDate": "2021-11-19",
"departureTime": "20:25",
"bookingClass": "V",
"flightStatusCode": "NN"
},
{
"flightNumber": 77,
"airlineCode": "EY",
"fromAirportCode": "AUH",
"toAirportCode": "AMS",
"departureDate": "2021-11-26",
"departureTime": "09:00",
"bookingClass": "V",
"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",
"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 \"reasonForIssuance\": \"BAGGAGE\",\n \"subcode\": \"0C2\",\n \"airlineCode\": \"EY\",\n \"electronicMiscellaneousDocumentType\": \"FLIGHT_COUPON_ASSOCIATED\",\n \"basePrice\": \"528.00\",\n \"currencyCode\": \"USD\",\n \"groupCode\": \"BG\",\n \"flightIndices\": [\n 1\n ]\n },\n {\n \"reasonForIssuance\": \"BAGGAGE\",\n \"subcode\": \"0C4\",\n \"airlineCode\": \"EY\",\n \"electronicMiscellaneousDocumentType\": \"FLIGHT_COUPON_ASSOCIATED\",\n \"basePrice\": \"656.00\",\n \"currencyCode\": \"USD\",\n \"groupCode\": \"BG\",\n \"flightIndices\": [\n 1\n ]\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\": 78,\n \"airlineCode\": \"EY\",\n \"fromAirportCode\": \"AMS\",\n \"toAirportCode\": \"AUH\",\n \"departureDate\": \"2021-11-19\",\n \"departureTime\": \"20:25\",\n \"bookingClass\": \"V\",\n \"flightStatusCode\": \"NN\"\n },\n {\n \"flightNumber\": 77,\n \"airlineCode\": \"EY\",\n \"fromAirportCode\": \"AUH\",\n \"toAirportCode\": \"AMS\",\n \"departureDate\": \"2021-11-26\",\n \"departureTime\": \"09:00\",\n \"bookingClass\": \"V\",\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": [
]
}