Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
; Use this online tool to generate code from sample JSON: Generate Code to Create JSON
; The following JSON is sent in the request body.
; {
; "blocks": [
; {
; "blockIdList": [
; {
; "type": "Block",
; "idContext": "OPERA",
; "id": "{{BlockId}}"
; }
; ],
; "comments": {
; "commentInfo": [
; {
; "comment": {
; "commentTitle": "Block note title",
; "type": "BOOK",
; "internal": true,
; "hotelId": "{{HotelId}}",
; "text": {
; "value": "Block notes can go here"
; }
; }
; }
; ]
; },
; "hotelId": "{{HotelId}}",
; "markAsRecentlyAccessed": false
; }
; ]
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("blocks[0].blockIdList[0].type","Block")
$oJson.UpdateString("blocks[0].blockIdList[0].idContext","OPERA")
$oJson.UpdateString("blocks[0].blockIdList[0].id","{{BlockId}}")
$oJson.UpdateString("blocks[0].comments.commentInfo[0].comment.commentTitle","Block note title")
$oJson.UpdateString("blocks[0].comments.commentInfo[0].comment.type","BOOK")
$oJson.UpdateBool("blocks[0].comments.commentInfo[0].comment.internal",True)
$oJson.UpdateString("blocks[0].comments.commentInfo[0].comment.hotelId","{{HotelId}}")
$oJson.UpdateString("blocks[0].comments.commentInfo[0].comment.text.value","Block notes can go here")
$oJson.UpdateString("blocks[0].hotelId","{{HotelId}}")
$oJson.UpdateBool("blocks[0].markAsRecentlyAccessed",False)
$oHttp.SetRequestHeader "x-app-key","{{AppKey}}"
$oHttp.SetRequestHeader "x-hotelid","{{HotelId}}"
; Adds the "Authorization: Bearer <access_token>" header.
$oHttp.AuthToken = "<access_token>"
$oSbRequestBody = ObjCreate("Chilkat.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
Local $oResp = $oHttp.PTextSb("PUT","https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}",$oSbRequestBody,"utf-8","application/json",False,False)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "x-hotelid: {{HotelId}}"
-H "x-app-key: {{AppKey}}"
-d '{
"blocks": [
{
"blockIdList": [
{
"type": "Block",
"idContext": "OPERA",
"id": "{{BlockId}}"
}
],
"comments": {
"commentInfo": [
{
"comment": {
"commentTitle": "Block note title",
"type": "BOOK",
"internal": true,
"hotelId": "{{HotelId}}",
"text": {
"value": "Block notes can go here"
}
}
}
]
},
"hotelId": "{{HotelId}}",
"markAsRecentlyAccessed": false
}
]
}'
https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}
Postman Collection Item JSON
{
"name": "Add notes to a block",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "x-hotelid",
"value": "{{HotelId}}"
},
{
"key": "x-app-key",
"value": "{{AppKey}}"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"blocks\": [\r\n {\r\n \"blockIdList\": [\r\n {\r\n \"type\": \"Block\",\r\n \"idContext\": \"OPERA\",\r\n \"id\": \"{{BlockId}}\"\r\n }\r\n ],\r\n \"comments\": {\r\n \"commentInfo\": [\r\n {\r\n \"comment\": {\r\n \"commentTitle\": \"Block note title\",\r\n \"type\": \"BOOK\",\r\n \"internal\": true,\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"text\": {\r\n \"value\": \"Block notes can go here\"\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"markAsRecentlyAccessed\": false\r\n }\r\n ]\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HostName}}/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}",
"host": [
"{{HostName}}"
],
"path": [
"blk",
"v0",
"hotels",
"{{HotelId}}",
"blocks",
"{{BlockId}}"
]
}
},
"response": [
]
}