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.
// {
// "OTA_AirLowFareSearchRQ": {
// "Version": "2",
// "POS": {
// "Source": [
// {
// "PseudoCityCode": "{{pcc}}",
// "RequestorID": {
// "Type": "1",
// "ID": "1",
// "CompanyName": {
// "Code": "TN"
// }
// }
// }
// ]
// },
// "OriginDestinationInformation": [
// {
// "RPH": "1",
// "DepartureDateTime": "{{start_date}}T00:00:00",
// "OriginLocation": {
// "LocationCode": "YVR"
// },
// "DestinationLocation": {
// "LocationCode": "YYC"
// }
// }
// ],
// "TravelPreferences": {
// "MaxStopsQuantity": 0,
// "VendorPref": [
// {
// "Code": "AC"
// }
// ],
// "TPA_Extensions": {
// "NumTrips": {
// "Number": 10
// },
// "DataSources": {
// "NDC": "Disable",
// "ATPCO": "Enable",
// "LCC": "Disable"
// }
// }
// },
// "TravelerInfoSummary": {
// "AirTravelerAvail": [
// {
// "PassengerTypeQuantity": [
// {
// "Code": "ADT",
// "Quantity": 1
// }
// ]
// }
// ]
// },
// "TPA_Extensions": {
// "IntelliSellTransaction": {
// "RequestType": {
// "Name": "200ITINS"
// }
// }
// }
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.Version",L"2");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.POS.Source[0].PseudoCityCode",L"{{pcc}}");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.POS.Source[0].RequestorID.Type",L"1");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.POS.Source[0].RequestorID.ID",L"1");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.POS.Source[0].RequestorID.CompanyName.Code",L"TN");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].RPH",L"1");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].DepartureDateTime",L"{{start_date}}T00:00:00");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].OriginLocation.LocationCode",L"YVR");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].DestinationLocation.LocationCode",L"YYC");
CkJsonObjectW_UpdateInt(json,L"OTA_AirLowFareSearchRQ.TravelPreferences.MaxStopsQuantity",0);
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.TravelPreferences.VendorPref[0].Code",L"AC");
CkJsonObjectW_UpdateInt(json,L"OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.NumTrips.Number",10);
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.DataSources.NDC",L"Disable");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.DataSources.ATPCO",L"Enable");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.DataSources.LCC",L"Disable");
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.TravelerInfoSummary.AirTravelerAvail[0].PassengerTypeQuantity[0].Code",L"ADT");
CkJsonObjectW_UpdateInt(json,L"OTA_AirLowFareSearchRQ.TravelerInfoSummary.AirTravelerAvail[0].PassengerTypeQuantity[0].Quantity",1);
CkJsonObjectW_UpdateString(json,L"OTA_AirLowFareSearchRQ.TPA_Extensions.IntelliSellTransaction.RequestType.Name",L"200ITINS");
CkHttpW_SetRequestHeader(http,L"Conversation-ID",L"{{conv_id}}");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
resp = CkHttpW_PostJson3(http,L"https://domain.com/v2/offers/shop",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 "Content-Type: application/json"
-H "Conversation-ID: {{conv_id}}"
-d '{
"OTA_AirLowFareSearchRQ": {
"Version": "2",
"POS": {
"Source": [{
"PseudoCityCode": "{{pcc}}",
"RequestorID": {
"Type": "1",
"ID": "1",
"CompanyName": {
"Code": "TN"
}
}
}
]
},
"OriginDestinationInformation": [{
"RPH": "1",
"DepartureDateTime": "{{start_date}}T00:00:00",
"OriginLocation": {
"LocationCode": "YVR"
},
"DestinationLocation": {
"LocationCode": "YYC"
}
}
],
"TravelPreferences": {
"MaxStopsQuantity": 0,
"VendorPref": [
{
"Code" : "AC"
}
],
"TPA_Extensions": {
"NumTrips": {
"Number": 10
},
"DataSources": {
"NDC": "Disable",
"ATPCO": "Enable",
"LCC": "Disable"
}
}
},
"TravelerInfoSummary": {
"AirTravelerAvail": [{
"PassengerTypeQuantity": [{
"Code": "ADT",
"Quantity": 1
}
]
}
]
},
"TPA_Extensions": {
"IntelliSellTransaction": {
"RequestType": {
"Name": "200ITINS"
}
}
}
}
}'
https://domain.com/v2/offers/shop
Postman Collection Item JSON
{
"name": "1. Shop (BFM)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const itinNumber = 0;",
"",
"var jsonData = JSON.parse(responseBody);",
"var outboundData = jsonData.groupedItineraryResponse.scheduleDescs[0];",
"",
"",
"pm.environment.set(\"oFlightNumber\", outboundData.carrier.marketingFlightNumber);",
"pm.environment.set(\"oResBookDesigCode\", outboundData.ResBookDesigCode);",
"pm.environment.set(\"oDepartureTime\", outboundData.departure.time.substring(0, 5));",
"pm.environment.set(\"oDepartureAirport\", outboundData.departure.airport);",
"pm.environment.set(\"oArrivalAirport\", outboundData.arrival.airport);",
"pm.environment.set(\"oMarketingAirline\", outboundData.carrier.marketing);",
"pm.environment.set(\"oOperatingAirline\", outboundData.carrier.operating);",
"",
""
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Conversation-ID",
"value": "{{conv_id}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"OTA_AirLowFareSearchRQ\": {\n \"Version\": \"2\",\n \"POS\": {\n \"Source\": [{\n \"PseudoCityCode\": \"{{pcc}}\",\n \"RequestorID\": {\n \"Type\": \"1\",\n \"ID\": \"1\",\n \"CompanyName\": {\n \"Code\": \"TN\"\n }\n }\n }\n ]\n },\n \"OriginDestinationInformation\": [{\n \"RPH\": \"1\",\n \"DepartureDateTime\": \"{{start_date}}T00:00:00\",\n \"OriginLocation\": {\n \"LocationCode\": \"YVR\"\n },\n \"DestinationLocation\": {\n \"LocationCode\": \"YYC\"\n }\n }\n ],\n \"TravelPreferences\": {\n \"MaxStopsQuantity\": 0, \n \t\t\t\"VendorPref\": [\n\t\t\t\t{\n\t\t\t\t\t\"Code\" : \"AC\"\n\t\t\t\t}\n\t\t\t],\n \"TPA_Extensions\": {\n \"NumTrips\": {\n \"Number\": 10\n },\n \"DataSources\": {\n \"NDC\": \"Disable\",\n \"ATPCO\": \"Enable\",\n \"LCC\": \"Disable\"\n }\n\n \n\n }\n },\n \"TravelerInfoSummary\": {\n \"AirTravelerAvail\": [{\n \"PassengerTypeQuantity\": [{\n \"Code\": \"ADT\",\n \"Quantity\": 1\n }\n ]\n }\n\n ]\n },\n \"TPA_Extensions\": {\n \"IntelliSellTransaction\": {\n \"RequestType\": {\n \"Name\": \"200ITINS\"\n }\n }\n }\n }\n}"
},
"url": {
"raw": "{{rest_endpoint}}/v2/offers/shop",
"host": [
"{{rest_endpoint}}"
],
"path": [
"v2",
"offers",
"shop"
]
},
"description": "[//]: # \"Start\"\n\n<b>[Description](https://developer.sabre.com/docs/rest_apis/air/search/bargain_finder_max/versions/v430), [Resources](https://developer.sabre.com/docs/rest_apis/air/search/bargain_finder_max/versions/v430/reference-documentation)</b>\n\n[//]: # \"End\""
},
"response": [
]
}