Chilkat Online Tools

unicodeCpp / Booking Management API v2021.12 / 5. Refund Flight Tickets

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>

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

    CkHttpW http;
    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.

    // {
    //   "tickets": [
    //     {
    //       "number": "{{ticket1}}"
    //     },
    //     {
    //       "number": "{{ticket2}}"
    //     }
    //   ]
    // }

    CkJsonObjectW json;
    json.UpdateString(L"tickets[0].number",L"{{ticket1}}");
    json.UpdateString(L"tickets[1].number",L"{{ticket2}}");

    http.SetRequestHeader(L"Conversation-ID",L"{{conv_id}}");
    http.SetRequestHeader(L"Content-Type",L"application/json");
    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken(L"<access_token>");

    CkHttpResponseW *resp = http.PostJson3(L"https://domain.com/v1/trip/orders/refundFlightTickets",L"application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%d\n",resp->get_StatusCode());
    wprintf(L"%s\n",resp->bodyStr());
    delete resp;
    }

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "Conversation-ID: {{conv_id}}"
	-d '{
  "tickets": [
      {
        "number": "{{ticket1}}"
      },
      {
        "number": "{{ticket2}}"
      }
  ]
}'
https://domain.com/v1/trip/orders/refundFlightTickets

Postman Collection Item JSON

{
  "name": "5. Refund Flight Tickets",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "type": "text",
        "value": "application/json"
      },
      {
        "key": "Conversation-ID",
        "type": "text",
        "value": "{{conv_id}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"tickets\": [\n      {\n        \"number\": \"{{ticket1}}\"\n      },\n      {\n        \"number\": \"{{ticket2}}\"\n      }\n  ]\n}"
    },
    "url": {
      "raw": "{{rest_endpoint}}/v1/trip/orders/refundFlightTickets",
      "host": [
        "{{rest_endpoint}}"
      ],
      "path": [
        "v1",
        "trip",
        "orders",
        "refundFlightTickets"
      ]
    },
    "description": "[//]: # \"Start\"\n\n<b>[Description](https://developer.sabre.com/docs/rest_apis/trip/orders/booking_management), [Resources](https://developer.sabre.com/docs/rest_apis/trip/orders/booking_management/reference-documentation), [Help](https://developer.sabre.com/docs/rest_apis/trip/orders/booking_management/help)</b>\n\n[//]: # \"End\""
  },
  "response": [
  ]
}