Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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"
// }
// }
// }
// }
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "AirTicketRQ.DesignatePrinter.Printers.Ticket.CountryCode" "AT" To iSuccess
Get ComUpdateString Of hoJson "AirTicketRQ.Itinerary.ID" "{{pnr}}" To iSuccess
Get ComUpdateString Of hoJson "AirTicketRQ.Ticketing[0].FOP_Qualifiers.BasicFOP.Type" "CA" To iSuccess
Get ComUpdateString Of hoJson "AirTicketRQ.PostProcessing.EndTransaction.Source.ReceivedFrom" "API TEST" To iSuccess
Send ComSetRequestHeader To hoHttp "accept" "application/json"
Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
// Adds the "Authorization: Bearer <access_token>" header.
Set ComAuthToken Of hoHttp To "<access_token>"
Get pvComObject of hoJson to vJson
Get ComPostJson3 Of hoHttp "https://domain.com/v1.2.0/air/ticket" "application/json" vJson To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln iTemp1
Get ComBodyStr Of hoResp To sTemp1
Showln sTemp1
Send Destroy of hoResp
End_Procedure
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": [
]
}