Chilkat Online Tools

unicodeC / ORACLE Hospitality OPERA Cloud REST API Workflows / Check-In a Guest

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

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

    // The following JSON is sent in the request body.

    // {
    //   "reservation": {
    //     "roomId": "{{RoomId}}",
    //     "ignoreWarnings": true,
    //     "stopCheckin": false,
    //     "printRegistration": false
    //   },
    //   "fetchReservationInstruction": [
    //     "ReservationDetail"
    //   ],
    //   "includeNotifications": true
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"reservation.roomId",L"{{RoomId}}");
    CkJsonObjectW_UpdateBool(json,L"reservation.ignoreWarnings",TRUE);
    CkJsonObjectW_UpdateBool(json,L"reservation.stopCheckin",FALSE);
    CkJsonObjectW_UpdateBool(json,L"reservation.printRegistration",FALSE);
    CkJsonObjectW_UpdateString(json,L"fetchReservationInstruction[0]",L"ReservationDetail");
    CkJsonObjectW_UpdateBool(json,L"includeNotifications",TRUE);

    CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
    CkHttpW_SetRequestHeader(http,L"x-app-key",L"{{AppKey}}");
    CkHttpW_SetRequestHeader(http,L"x-hotelid",L"{{HotelId}}");
    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");

    resp = CkHttpW_PostJson3(http,L"https://domain.com/fof/v1/hotels/{{HotelId}}/reservations/{{ReservationId}}/checkIns",L"application/json",json);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);

    }

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "x-app-key: {{AppKey}}"
	-H "x-hotelid: {{HotelId}}"
	-d '{
  "reservation": {
    "roomId": "{{RoomId}}",
    "ignoreWarnings": true,
    "stopCheckin": false,
    "printRegistration": false
  },
  "fetchReservationInstruction": [
    "ReservationDetail"
  ],
  "includeNotifications": true
}'
https://domain.com/fof/v1/hotels/{{HotelId}}/reservations/{{ReservationId}}/checkIns

Postman Collection Item JSON

{
  "name": "Check-In a Guest",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{Token}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "type": "text",
        "value": "application/json"
      },
      {
        "key": "x-app-key",
        "type": "text",
        "value": "{{AppKey}}"
      },
      {
        "key": "x-hotelid",
        "type": "text",
        "value": "{{HotelId}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n  \"reservation\": {\r\n    \"roomId\": \"{{RoomId}}\",\r\n    \"ignoreWarnings\": true,\r\n    \"stopCheckin\": false,\r\n    \"printRegistration\": false\r\n  },\r\n  \"fetchReservationInstruction\": [\r\n    \"ReservationDetail\"\r\n  ],\r\n  \"includeNotifications\": true\r\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{HostName}}/fof/v1/hotels/{{HotelId}}/reservations/{{ReservationId}}/checkIns",
      "host": [
        "{{HostName}}"
      ],
      "path": [
        "fof",
        "v1",
        "hotels",
        "{{HotelId}}",
        "reservations",
        "{{ReservationId}}",
        "checkIns"
      ],
      "query": [
        {
          "key": "fetchInstructions",
          "value": "Reservation",
          "disabled": true
        }
      ]
    },
    "description": "To check in a guest at the property."
  },
  "response": [
  ]
}