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, 'Active', 'true'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'Status', 'Approved'
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'PageSize', 10
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'PageNumber', 1
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'OrderDirections', 'Descending'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept-Language', 'en'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://domain.com/api/v1.0/codetypes/requests/my', @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 "Active=true"
-d "Status=Approved"
-d "PageSize=10"
-d "PageNumber=1"
-d "OrderDirections=Descending"
-H "Authorization: Bearer <access_token>"
-H "Accept-Language: en"
https://domain.com/api/v1.0/codetypes/requests/my
Postman Collection Item JSON
{
"name": "7. Search my EGS code usage requests",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{generatedAccessToken}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Accept-Language",
"value": "en",
"type": "text"
}
],
"url": {
"raw": "{{apiBaseUrl}}/api/v1.0/codetypes/requests/my?Active=true&Status=Approved&PageSize=10&PageNumber=1&OrderDirections=Descending",
"host": [
"{{apiBaseUrl}}"
],
"path": [
"api",
"v1.0",
"codetypes",
"requests",
"my"
],
"query": [
{
"key": "ItemCode",
"value": "EG-100027962-1208617",
"disabled": true
},
{
"key": "CodeName",
"value": "Code Name",
"disabled": true
},
{
"key": "CodeDescription",
"value": "Perf Test Desc",
"disabled": true
},
{
"key": "ParentLevelName",
"value": "EGS Level 4 Code",
"disabled": true
},
{
"key": "ParentItemCode",
"value": "100000",
"disabled": true
},
{
"key": "ActiveFrom",
"value": "2021-03-21T00:00:00Z",
"disabled": true
},
{
"key": "ActiveTo",
"value": "2021-05-21T23:59:00Z",
"disabled": true
},
{
"key": "Active",
"value": "true"
},
{
"key": "Status",
"value": "Approved"
},
{
"key": "PageSize",
"value": "10"
},
{
"key": "PageNumber",
"value": "1"
},
{
"key": "OrderDirections",
"value": "Descending"
},
{
"key": "RequestType",
"value": "New",
"disabled": true
}
]
}
},
"response": [
]
}