Chilkat Online Tools

Foxpro / ORACLE Hospitality OPERA Cloud REST API Workflows / Create a Posting Master Reservation on the block

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

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

* The following JSON is sent in the request body.

* {
*   "criteria": {
*     "hotelId": "{{HotelId}}",
*     "blockId": {
*       "type": "Block",
*       "idContext": "OPERA",
*       "id": "{{BlockId}}"
*     },
*     "responseInstruction": {
*       "fetchFullReservation": false
*     }
*   }
* }

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("criteria.hotelId","{{HotelId}}")
loJson.UpdateString("criteria.blockId.type","Block")
loJson.UpdateString("criteria.blockId.idContext","OPERA")
loJson.UpdateString("criteria.blockId.id","{{BlockId}}")
loJson.UpdateBool("criteria.responseInstruction.fetchFullReservation",0)

loHttp.SetRequestHeader("x-app-key","{{AppKey}}")
loHttp.SetRequestHeader("x-hotelid","{{HotelId}}")
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"

loResp = loHttp.PostJson3("https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/postingMaster","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp

RELEASE loHttp
RELEASE loJson

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "x-hotelid: {{HotelId}}"
	-H "x-app-key: {{AppKey}}"
	-d '{
    "criteria": {
        "hotelId": "{{HotelId}}",
        "blockId": {
            "type": "Block",
            "idContext": "OPERA",
            "id": "{{BlockId}}"
        },
        "responseInstruction": {
            "fetchFullReservation": false
        }
    }
}'
https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/postingMaster

Postman Collection Item JSON

{
  "name": "Create a Posting Master Reservation on the block",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{Token}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
      {
        "key": "x-hotelid",
        "value": "{{HotelId}}"
      },
      {
        "key": "x-app-key",
        "value": "{{AppKey}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n    \"criteria\": {\r\n        \"hotelId\": \"{{HotelId}}\",\r\n        \"blockId\": {\r\n            \"type\": \"Block\",\r\n            \"idContext\": \"OPERA\",\r\n            \"id\": \"{{BlockId}}\"\r\n        },\r\n        \"responseInstruction\": {\r\n            \"fetchFullReservation\": false\r\n        }\r\n    }\r\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{HostName}}/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/postingMaster",
      "host": [
        "{{HostName}}"
      ],
      "path": [
        "blk",
        "v0",
        "hotels",
        "{{HotelId}}",
        "blocks",
        "{{BlockId}}",
        "postingMaster"
      ]
    }
  },
  "response": [
  ]
}