Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- 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"
-- }
-- }
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.address.name', 'John Smith'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.address.street', '1230 Ellen Ave, apt 10'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.address.city', 'Dallas'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.address.stateProvince', 'TX'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.address.postalCode', '75063'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.address.countryCode', 'US'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.address.freeText', 'John Smith' + CHAR(10) + '1230 Ellen Ave, apt 10' + CHAR(10) + 'Dallas, TX 75063' + CHAR(10) + 'US'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.agencyCustomerNumber', '1234567'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'agency.ticketingPolicy', 'TODAY'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].givenName', 'John'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].surname', 'Smith'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].birthDate', '1970-01-23'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].passengerCode', 'ADT'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].reasonForIssuanceCode', 'C'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].electronicMiscellaneousDocumentType', 'FLIGHT_COUPON_ASSOCIATED'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].reasonForIssuanceName', 'BAGGAGE'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].subcode', '0CC'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].airlineCode', 'LH'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].groupCode', 'BG'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].basePrice', '35.00'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].ancillaries[0].currencyCode', 'USD'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'travelers[0].ancillaries[0].flightIndices[0]', 1
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[0].specialServices[0].code', 'FBAG'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[1].givenName', 'Mary'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[1].surname', 'Smith'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[1].birthDate', '1970-01-23'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'travelers[1].passengerCode', 'ADT'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'contactInfo.emails[0]', 'travel@sabre.com'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'contactInfo.emails[1]', 'travel2@sabre.com'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'contactInfo.phones[0]', '+123456'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'flightDetails.flights[0].flightNumber', 809
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'flightDetails.flights[0].airlineCode', 'LH'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'flightDetails.flights[0].fromAirportCode', 'ARN'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'flightDetails.flights[0].toAirportCode', 'FRA'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'flightDetails.flights[0].departureDate', '2021-11-20'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'flightDetails.flights[0].departureTime', '06:15'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'flightDetails.flights[0].bookingClass', 'Y'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'flightDetails.flights[0].flightStatusCode', 'NN'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment.billingAddress.name', 'John Smith'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment.billingAddress.street', '1230 Ellen Ave, apt 10'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment.billingAddress.city', 'Dallas'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment.billingAddress.stateProvince', 'TX'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment.billingAddress.postalCode', '75063'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'payment.billingAddress.countryCode', 'US'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'accept', 'application/json'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-Sabre-Group', 'G7RE'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-Sabre-Current-City', 'G7RE'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/', 'application/json', @json
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
END
GO
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": [
]
}