Chilkat Online Tools

Objective-C / Booking Management API v2021.12 / createBooking - Ancillaries baggage

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoHttp *http = [[CkoHttp alloc] init];
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": [
//         {
//           "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"
//     }
//   }
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"agency.address.name" value: @"John Smith"];
[json UpdateString: @"agency.address.street" value: @"1230 Ellen Ave, apt 10"];
[json UpdateString: @"agency.address.city" value: @"Dallas"];
[json UpdateString: @"agency.address.stateProvince" value: @"TX"];
[json UpdateString: @"agency.address.postalCode" value: @"75063"];
[json UpdateString: @"agency.address.countryCode" value: @"US"];
[json UpdateString: @"agency.address.freeText" value: @"John Smith\n1230 Ellen Ave, apt 10\nDallas, TX 75063\nUS"];
[json UpdateString: @"agency.agencyCustomerNumber" value: @"1234567"];
[json UpdateString: @"agency.ticketingPolicy" value: @"TODAY"];
[json UpdateString: @"travelers[0].givenName" value: @"John"];
[json UpdateString: @"travelers[0].surname" value: @"Smith"];
[json UpdateString: @"travelers[0].birthDate" value: @"1970-01-23"];
[json UpdateString: @"travelers[0].passengerCode" value: @"ADT"];
[json UpdateString: @"travelers[0].ancillaries[0].reasonForIssuance" value: @"BAGGAGE"];
[json UpdateString: @"travelers[0].ancillaries[0].subcode" value: @"0C2"];
[json UpdateString: @"travelers[0].ancillaries[0].airlineCode" value: @"EY"];
[json UpdateString: @"travelers[0].ancillaries[0].electronicMiscellaneousDocumentType" value: @"FLIGHT_COUPON_ASSOCIATED"];
[json UpdateString: @"travelers[0].ancillaries[0].basePrice" value: @"528.00"];
[json UpdateString: @"travelers[0].ancillaries[0].currencyCode" value: @"USD"];
[json UpdateString: @"travelers[0].ancillaries[0].groupCode" value: @"BG"];
[json UpdateInt: @"travelers[0].ancillaries[0].flightIndices[0]" value: [NSNumber numberWithInt: 1]];
[json UpdateString: @"travelers[0].ancillaries[1].reasonForIssuance" value: @"BAGGAGE"];
[json UpdateString: @"travelers[0].ancillaries[1].subcode" value: @"0C4"];
[json UpdateString: @"travelers[0].ancillaries[1].airlineCode" value: @"EY"];
[json UpdateString: @"travelers[0].ancillaries[1].electronicMiscellaneousDocumentType" value: @"FLIGHT_COUPON_ASSOCIATED"];
[json UpdateString: @"travelers[0].ancillaries[1].basePrice" value: @"656.00"];
[json UpdateString: @"travelers[0].ancillaries[1].currencyCode" value: @"USD"];
[json UpdateString: @"travelers[0].ancillaries[1].groupCode" value: @"BG"];
[json UpdateInt: @"travelers[0].ancillaries[1].flightIndices[0]" value: [NSNumber numberWithInt: 1]];
[json UpdateString: @"travelers[1].givenName" value: @"Mary"];
[json UpdateString: @"travelers[1].surname" value: @"Smith"];
[json UpdateString: @"travelers[1].birthDate" value: @"1970-01-23"];
[json UpdateString: @"travelers[1].passengerCode" value: @"ADT"];
[json UpdateString: @"contactInfo.emails[0]" value: @"travel@sabre.com"];
[json UpdateString: @"contactInfo.emails[1]" value: @"travel2@sabre.com"];
[json UpdateString: @"contactInfo.phones[0]" value: @"+123456"];
[json UpdateInt: @"flightDetails.flights[0].flightNumber" value: [NSNumber numberWithInt: 78]];
[json UpdateString: @"flightDetails.flights[0].airlineCode" value: @"EY"];
[json UpdateString: @"flightDetails.flights[0].fromAirportCode" value: @"AMS"];
[json UpdateString: @"flightDetails.flights[0].toAirportCode" value: @"AUH"];
[json UpdateString: @"flightDetails.flights[0].departureDate" value: @"2021-11-19"];
[json UpdateString: @"flightDetails.flights[0].departureTime" value: @"20:25"];
[json UpdateString: @"flightDetails.flights[0].bookingClass" value: @"V"];
[json UpdateString: @"flightDetails.flights[0].flightStatusCode" value: @"NN"];
[json UpdateInt: @"flightDetails.flights[1].flightNumber" value: [NSNumber numberWithInt: 77]];
[json UpdateString: @"flightDetails.flights[1].airlineCode" value: @"EY"];
[json UpdateString: @"flightDetails.flights[1].fromAirportCode" value: @"AUH"];
[json UpdateString: @"flightDetails.flights[1].toAirportCode" value: @"AMS"];
[json UpdateString: @"flightDetails.flights[1].departureDate" value: @"2021-11-26"];
[json UpdateString: @"flightDetails.flights[1].departureTime" value: @"09:00"];
[json UpdateString: @"flightDetails.flights[1].bookingClass" value: @"V"];
[json UpdateString: @"flightDetails.flights[1].flightStatusCode" value: @"NN"];
[json UpdateString: @"payment.billingAddress.name" value: @"John Smith"];
[json UpdateString: @"payment.billingAddress.street" value: @"1230 Ellen Ave, apt 10"];
[json UpdateString: @"payment.billingAddress.city" value: @"Dallas"];
[json UpdateString: @"payment.billingAddress.stateProvince" value: @"TX"];
[json UpdateString: @"payment.billingAddress.postalCode" value: @"75063"];
[json UpdateString: @"payment.billingAddress.countryCode" value: @"US"];

[http SetRequestHeader: @"accept" value: @"application/json"];
[http SetRequestHeader: @"Content-Type" value: @"application/json"];
[http SetRequestHeader: @"X-Sabre-Group" value: @"G7RE"];
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = @"<access_token>";
[http SetRequestHeader: @"X-Sabre-Current-City" value: @"G7RE"];

CkoHttpResponse *resp = [http PostJson3: @"https://domain.com/" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

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": [
  ]
}