Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
* 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"
* }
* }
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("agency.address.name","John Smith")
loJson.UpdateString("agency.address.street","1230 Ellen Ave, apt 10")
loJson.UpdateString("agency.address.city","Dallas")
loJson.UpdateString("agency.address.stateProvince","TX")
loJson.UpdateString("agency.address.postalCode","75063")
loJson.UpdateString("agency.address.countryCode","US")
loJson.UpdateString("agency.address.freeText","John Smith" + CHR(10) + "1230 Ellen Ave, apt 10" + CHR(10) + "Dallas, TX 75063" + CHR(10) + "US")
loJson.UpdateString("agency.agencyCustomerNumber","1234567")
loJson.UpdateString("agency.ticketingPolicy","TODAY")
loJson.UpdateString("travelers[0].givenName","John")
loJson.UpdateString("travelers[0].surname","Smith")
loJson.UpdateString("travelers[0].birthDate","1970-01-23")
loJson.UpdateString("travelers[0].passengerCode","ADT")
loJson.UpdateString("travelers[0].ancillaries[0].reasonForIssuance","BAGGAGE")
loJson.UpdateString("travelers[0].ancillaries[0].subcode","0C2")
loJson.UpdateString("travelers[0].ancillaries[0].airlineCode","EY")
loJson.UpdateString("travelers[0].ancillaries[0].electronicMiscellaneousDocumentType","FLIGHT_COUPON_ASSOCIATED")
loJson.UpdateString("travelers[0].ancillaries[0].basePrice","528.00")
loJson.UpdateString("travelers[0].ancillaries[0].currencyCode","USD")
loJson.UpdateString("travelers[0].ancillaries[0].groupCode","BG")
loJson.UpdateInt("travelers[0].ancillaries[0].flightIndices[0]",1)
loJson.UpdateString("travelers[0].ancillaries[1].reasonForIssuance","BAGGAGE")
loJson.UpdateString("travelers[0].ancillaries[1].subcode","0C4")
loJson.UpdateString("travelers[0].ancillaries[1].airlineCode","EY")
loJson.UpdateString("travelers[0].ancillaries[1].electronicMiscellaneousDocumentType","FLIGHT_COUPON_ASSOCIATED")
loJson.UpdateString("travelers[0].ancillaries[1].basePrice","656.00")
loJson.UpdateString("travelers[0].ancillaries[1].currencyCode","USD")
loJson.UpdateString("travelers[0].ancillaries[1].groupCode","BG")
loJson.UpdateInt("travelers[0].ancillaries[1].flightIndices[0]",1)
loJson.UpdateString("travelers[1].givenName","Mary")
loJson.UpdateString("travelers[1].surname","Smith")
loJson.UpdateString("travelers[1].birthDate","1970-01-23")
loJson.UpdateString("travelers[1].passengerCode","ADT")
loJson.UpdateString("contactInfo.emails[0]","travel@sabre.com")
loJson.UpdateString("contactInfo.emails[1]","travel2@sabre.com")
loJson.UpdateString("contactInfo.phones[0]","+123456")
loJson.UpdateInt("flightDetails.flights[0].flightNumber",78)
loJson.UpdateString("flightDetails.flights[0].airlineCode","EY")
loJson.UpdateString("flightDetails.flights[0].fromAirportCode","AMS")
loJson.UpdateString("flightDetails.flights[0].toAirportCode","AUH")
loJson.UpdateString("flightDetails.flights[0].departureDate","2021-11-19")
loJson.UpdateString("flightDetails.flights[0].departureTime","20:25")
loJson.UpdateString("flightDetails.flights[0].bookingClass","V")
loJson.UpdateString("flightDetails.flights[0].flightStatusCode","NN")
loJson.UpdateInt("flightDetails.flights[1].flightNumber",77)
loJson.UpdateString("flightDetails.flights[1].airlineCode","EY")
loJson.UpdateString("flightDetails.flights[1].fromAirportCode","AUH")
loJson.UpdateString("flightDetails.flights[1].toAirportCode","AMS")
loJson.UpdateString("flightDetails.flights[1].departureDate","2021-11-26")
loJson.UpdateString("flightDetails.flights[1].departureTime","09:00")
loJson.UpdateString("flightDetails.flights[1].bookingClass","V")
loJson.UpdateString("flightDetails.flights[1].flightStatusCode","NN")
loJson.UpdateString("payment.billingAddress.name","John Smith")
loJson.UpdateString("payment.billingAddress.street","1230 Ellen Ave, apt 10")
loJson.UpdateString("payment.billingAddress.city","Dallas")
loJson.UpdateString("payment.billingAddress.stateProvince","TX")
loJson.UpdateString("payment.billingAddress.postalCode","75063")
loJson.UpdateString("payment.billingAddress.countryCode","US")
loHttp.SetRequestHeader("accept","application/json")
loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("X-Sabre-Group","G7RE")
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"
loHttp.SetRequestHeader("X-Sabre-Current-City","G7RE")
loResp = loHttp.PostJson3("https://domain.com/","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
CANCEL
ENDIF
? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp
RELEASE loHttp
RELEASE loJson
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": [
]
}