Chilkat Online Tools

TCL / Booking Management API v2021.12 / 3. airTicket

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

# Use this online tool to generate code from sample JSON: Generate Code to Create JSON

# The following JSON is sent in the request body.

# {
#   "AirTicketRQ": {
#     "DesignatePrinter": {
#       "Printers": {
#         "Ticket": {
#           "CountryCode": "AT"
#         }
#       }
#     },
#     "Itinerary": {
#       "ID": "{{pnr}}"
#     },
#     "Ticketing": [
#       {
#         "FOP_Qualifiers": {
#           "BasicFOP": {
#             "Type": "CA"
#           }
#         }
#       }
#     ],
#     "PostProcessing": {
#       "EndTransaction": {
#         "Source": {
#           "ReceivedFrom": "API TEST"
#         }
#       }
#     }
#   }
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "AirTicketRQ.DesignatePrinter.Printers.Ticket.CountryCode" "AT"
CkJsonObject_UpdateString $json "AirTicketRQ.Itinerary.ID" "{{pnr}}"
CkJsonObject_UpdateString $json "AirTicketRQ.Ticketing[0].FOP_Qualifiers.BasicFOP.Type" "CA"
CkJsonObject_UpdateString $json "AirTicketRQ.PostProcessing.EndTransaction.Source.ReceivedFrom" "API TEST"

CkHttp_SetRequestHeader $http "accept" "application/json"
CkHttp_SetRequestHeader $http "Content-Type" "application/json"
# Adds the "Authorization: Bearer <access_token>" header.
CkHttp_put_AuthToken $http "<access_token>"

# resp is a CkHttpResponse
set resp [CkHttp_PostJson3 $http "https://domain.com/v1.2.0/air/ticket" "application/json" $json]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    exit
}

puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp


delete_CkHttp $http
delete_CkJsonObject $json

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "accept: application/json"
	-H "Content-Type: application/json"
	-d '{
    "AirTicketRQ": {
        "DesignatePrinter": {
            "Printers": {
                "Ticket": {
                    "CountryCode": "AT"
                }
            }
        },
        "Itinerary": {
            "ID": "{{pnr}}"
        },
        "Ticketing": [
            {
                "FOP_Qualifiers": {
                    "BasicFOP": {
                        "Type": "CA"
                    }
                }
            }
        ],
        "PostProcessing": {
            "EndTransaction": {
                "Source": {
                    "ReceivedFrom": "API TEST"
                }
            }
        }
    }
}'
https://domain.com/v1.2.0/air/ticket

Postman Collection Item JSON

{
  "name": "3. airTicket",
  "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"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"AirTicketRQ\": {\n        \"DesignatePrinter\": {\n            \"Printers\": {\n                \"Ticket\": {\n                    \"CountryCode\": \"AT\"\n                }\n            }\n        },\n        \"Itinerary\": {\n            \"ID\": \"{{pnr}}\"\n        },\n        \"Ticketing\": [\n            {\n                \"FOP_Qualifiers\": {\n                    \"BasicFOP\": {\n                        \"Type\": \"CA\"\n                    }\n                }\n            }\n        ],\n        \"PostProcessing\": {\n            \"EndTransaction\": {\n                \"Source\": {\n                    \"ReceivedFrom\": \"API TEST\"\n                }\n            }\n        }\n    }\n}"
    },
    "url": {
      "raw": "{{rest_endpoint}}/v1.2.0/air/ticket",
      "host": [
        "{{rest_endpoint}}"
      ],
      "path": [
        "v1.2.0",
        "air",
        "ticket"
      ]
    },
    "description": "### <br>"
  },
  "response": [
  ]
}