Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterName', 'HotelCode'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterValue', '{{HotelId}}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterName', 'EventType'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterValue', 'BRKFT'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterName', 'Event_Start'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterValue', '2021-06-09 08:00:00.0'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterName', 'Event_End'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'parameterValue', '2010-06-09 09:00:00.0'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'includeInactiveFlag', 'false'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'x-app-key', '{{AppKey}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'x-hotelid', '{{HotelId}}'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://domain.com/lov/v1/listOfValues/AvailableSpaces', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
END
GO
Curl Command
curl -G -d "parameterName=HotelCode"
-d "parameterValue=%7B%7BHotelId%7D%7D"
-d "parameterName=EventType"
-d "parameterValue=BRKFT"
-d "parameterName=Event_Start"
-d "parameterValue=2021-06-09%2008%3A00%3A00.0"
-d "parameterName=Event_End"
-d "parameterValue=2010-06-09%2009%3A00%3A00.0"
-d "includeInactiveFlag=false"
-H "Authorization: Bearer <access_token>"
-H "x-app-key: {{AppKey}}"
-H "x-hotelid: {{HotelId}}"
https://domain.com/lov/v1/listOfValues/AvailableSpaces
Postman Collection Item JSON
{
"name": "Search Function Space Availability",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "x-app-key",
"type": "text",
"value": "{{AppKey}}"
},
{
"key": "x-hotelid",
"type": "text",
"value": "{{HotelId}}"
}
],
"url": {
"raw": "{{HostName}}/lov/v1/listOfValues/AvailableSpaces?parameterName=HotelCode¶meterValue={{HotelId}}¶meterName=EventType¶meterValue=BRKFT¶meterName=Event_Start¶meterValue=2021-06-09+08:00:00.0¶meterName=Event_End¶meterValue=2010-06-09+09:00:00.0&includeInactiveFlag=false",
"host": [
"{{HostName}}"
],
"path": [
"lov",
"v1",
"listOfValues",
"AvailableSpaces"
],
"query": [
{
"key": "parameterName",
"value": "HotelCode"
},
{
"key": "parameterValue",
"value": "{{HotelId}}"
},
{
"key": "parameterName",
"value": "EventType"
},
{
"key": "parameterValue",
"value": "BRKFT",
"description": "Event Type Code found from getEventTypes"
},
{
"key": "parameterName",
"value": "Event_Start"
},
{
"key": "parameterValue",
"value": "2021-06-09+08:00:00.0"
},
{
"key": "parameterName",
"value": "Event_End"
},
{
"key": "parameterValue",
"value": "2010-06-09+09:00:00.0"
},
{
"key": "includeInactiveFlag",
"value": "false"
}
]
}
},
"response": [
]
}