Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject queryParams;
HCkHttpResponse resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
queryParams = CkJsonObject_Create();
CkJsonObject_UpdateString(queryParams,"blockName","Oracle Conference");
CkJsonObject_UpdateString(queryParams,"hotelId","{{HotelId}}");
CkJsonObject_UpdateString(queryParams,"blockCodeTemplate","AAAAAAMMYY");
CkJsonObject_UpdateString(queryParams,"startDate","2021-08-20");
CkHttp_SetRequestHeader(http,"x-app-key","{{AppKey}}");
CkHttp_SetRequestHeader(http,"x-hotelid","{{HotelId}}");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,"<access_token>");
resp = CkHttp_QuickRequestParams(http,"GET","https://domain.com/blk/v0/defaultBlockCode",queryParams);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
return;
}
printf("%d\n",CkHttpResponse_getStatusCode(resp));
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(queryParams);
}
Curl Command
curl -G -d "blockName=Oracle%20Conference"
-d "hotelId=%7B%7BHotelId%7D%7D"
-d "blockCodeTemplate=AAAAAAMMYY"
-d "startDate=2021-08-20"
-H "Authorization: Bearer <access_token>"
-H "x-hotelid: {{HotelId}}"
-H "x-app-key: {{AppKey}}"
https://domain.com/blk/v0/defaultBlockCode
Postman Collection Item JSON
{
"name": "Get block default code to use in postBlock",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "x-hotelid",
"value": "{{HotelId}}"
},
{
"key": "x-app-key",
"value": "{{AppKey}}"
}
],
"url": {
"raw": "{{HostName}}/blk/v0/defaultBlockCode?blockName=Oracle Conference&hotelId={{HotelId}}&blockCodeTemplate=AAAAAAMMYY&startDate=2021-08-20",
"host": [
"{{HostName}}"
],
"path": [
"blk",
"v0",
"defaultBlockCode"
],
"query": [
{
"key": "blockName",
"value": "Oracle Conference",
"description": "Add your block Name here, free text"
},
{
"key": "hotelId",
"value": "{{HotelId}}"
},
{
"key": "blockCodeTemplate",
"value": "AAAAAAMMYY"
},
{
"key": "startDate",
"value": "2021-08-20"
}
]
}
},
"response": [
]
}