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, '$filter', 'ProcessKey eq ''PetStore_UpdatePet'''
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-UIPATH-OrganizationUnitId', '{{folderId}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://domain.com/odata/Releases', @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
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "@odata.context": "https://cloud.uipath.com/org/tenant/orchestrator_/odata/$metadata#Releases",
-- "@odata.count": 1,
-- "value": [
-- {
-- "Key": "ecde643a-3ec1-4a5c-b4ea-381759ee620a",
-- "ProcessKey": "PetStore_UpdatePet",
-- "ProcessVersion": "1.0.11",
-- "IsLatestVersion": false,
-- "IsProcessDeleted": false,
-- "Description": "Blank Process",
-- "Name": "Update existsing pet by ID",
-- "EnvironmentId": null,
-- "EnvironmentName": "",
-- "EntryPointId": null,
-- "InputArguments": null,
-- "ProcessType": "Process",
-- "SupportsMultipleEntryPoints": true,
-- "RequiresUserInteraction": true,
-- "AutoUpdate": false,
-- "FeedId": "ef94e92f-5f58-474b-963c-c3ef46391ca7",
-- "JobPriority": "Normal",
-- "CreationTime": "2021-03-11T13:11:38.837Z",
-- "OrganizationUnitId": 515128,
-- "OrganizationUnitFullyQualifiedName": "UnattendedProcesses",
-- "Id": 30155,
-- "Arguments": {
-- "Input": "[{\"name\":\"status\",\"type\":\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\",\"required\":false,\"hasDefault\":true}]",
-- "Output": null
-- },
-- "ProcessSettings": null
-- }
-- ]
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @Key nvarchar(4000)
DECLARE @ProcessKey nvarchar(4000)
DECLARE @ProcessVersion nvarchar(4000)
DECLARE @IsLatestVersion int
DECLARE @IsProcessDeleted int
DECLARE @Description nvarchar(4000)
DECLARE @Name nvarchar(4000)
DECLARE @EnvironmentId nvarchar(4000)
DECLARE @EnvironmentName nvarchar(4000)
DECLARE @EntryPointId nvarchar(4000)
DECLARE @InputArguments nvarchar(4000)
DECLARE @ProcessType nvarchar(4000)
DECLARE @SupportsMultipleEntryPoints int
DECLARE @RequiresUserInteraction int
DECLARE @AutoUpdate int
DECLARE @FeedId nvarchar(4000)
DECLARE @JobPriority nvarchar(4000)
DECLARE @CreationTime nvarchar(4000)
DECLARE @OrganizationUnitId int
DECLARE @OrganizationUnitFullyQualifiedName nvarchar(4000)
DECLARE @Id int
DECLARE @Input nvarchar(4000)
DECLARE @Output nvarchar(4000)
DECLARE @ProcessSettings nvarchar(4000)
DECLARE @odata_context nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @odata_context OUT, '"@odata.context"'
DECLARE @odata_count int
EXEC sp_OAMethod @jResp, 'IntOf', @odata_count OUT, '"@odata.count"'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'value'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @Key OUT, 'value[i].Key'
EXEC sp_OAMethod @jResp, 'StringOf', @ProcessKey OUT, 'value[i].ProcessKey'
EXEC sp_OAMethod @jResp, 'StringOf', @ProcessVersion OUT, 'value[i].ProcessVersion'
EXEC sp_OAMethod @jResp, 'BoolOf', @IsLatestVersion OUT, 'value[i].IsLatestVersion'
EXEC sp_OAMethod @jResp, 'BoolOf', @IsProcessDeleted OUT, 'value[i].IsProcessDeleted'
EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'value[i].Description'
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'value[i].Name'
EXEC sp_OAMethod @jResp, 'StringOf', @EnvironmentId OUT, 'value[i].EnvironmentId'
EXEC sp_OAMethod @jResp, 'StringOf', @EnvironmentName OUT, 'value[i].EnvironmentName'
EXEC sp_OAMethod @jResp, 'StringOf', @EntryPointId OUT, 'value[i].EntryPointId'
EXEC sp_OAMethod @jResp, 'StringOf', @InputArguments OUT, 'value[i].InputArguments'
EXEC sp_OAMethod @jResp, 'StringOf', @ProcessType OUT, 'value[i].ProcessType'
EXEC sp_OAMethod @jResp, 'BoolOf', @SupportsMultipleEntryPoints OUT, 'value[i].SupportsMultipleEntryPoints'
EXEC sp_OAMethod @jResp, 'BoolOf', @RequiresUserInteraction OUT, 'value[i].RequiresUserInteraction'
EXEC sp_OAMethod @jResp, 'BoolOf', @AutoUpdate OUT, 'value[i].AutoUpdate'
EXEC sp_OAMethod @jResp, 'StringOf', @FeedId OUT, 'value[i].FeedId'
EXEC sp_OAMethod @jResp, 'StringOf', @JobPriority OUT, 'value[i].JobPriority'
EXEC sp_OAMethod @jResp, 'StringOf', @CreationTime OUT, 'value[i].CreationTime'
EXEC sp_OAMethod @jResp, 'IntOf', @OrganizationUnitId OUT, 'value[i].OrganizationUnitId'
EXEC sp_OAMethod @jResp, 'StringOf', @OrganizationUnitFullyQualifiedName OUT, 'value[i].OrganizationUnitFullyQualifiedName'
EXEC sp_OAMethod @jResp, 'IntOf', @Id OUT, 'value[i].Id'
EXEC sp_OAMethod @jResp, 'StringOf', @Input OUT, 'value[i].Arguments.Input'
EXEC sp_OAMethod @jResp, 'StringOf', @Output OUT, 'value[i].Arguments.Output'
EXEC sp_OAMethod @jResp, 'StringOf', @ProcessSettings OUT, 'value[i].ProcessSettings'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -G -d "$filter=ProcessKey%20eq%20%27PetStore_UpdatePet%27"
-H "Authorization: Bearer <access_token>"
-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
https://domain.com/odata/Releases
Postman Collection Item JSON
{
"name": "Get Releases by Name",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"//set release key\r",
"var myResponse = pm.response.json();\r",
"pm.collectionVariables.set(\"releaseKey\", myResponse.value[0].Key);\r",
"console.log(pm.collectionVariables.get(\"releaseKey\"));"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-UIPATH-OrganizationUnitId",
"value": "{{folderId}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "{{url}}/odata/Releases?$filter=ProcessKey eq 'PetStore_UpdatePet'",
"host": [
"{{url}}"
],
"path": [
"odata",
"Releases"
],
"query": [
{
"key": "$filter",
"value": "ProcessKey eq 'PetStore_UpdatePet'"
}
]
},
"description": "The process arguments listed in the response property `Arguments` can be used to render a user interface. This allows to dyamically render a process user interface.\n\nIn this example we are using a simple `string`: status as process input argument. Simple input arguments are listed as key value pairs."
},
"response": [
{
"name": "Get Releases by Name",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "X-UIPATH-OrganizationUnitId",
"value": "{{folderId}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "{{url}}/odata/Releases?$filter=Name eq 'Update existsing pet by ID'",
"host": [
"{{url}}"
],
"path": [
"odata",
"Releases"
],
"query": [
{
"key": "$filter",
"value": "Name eq 'Update existsing pet by ID'"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 20 Apr 2021 09:04:25 GMT"
},
{
"key": "Content-Type",
"value": "application/json; odata.metadata=minimal; odata.streaming=true"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Expires",
"value": "-1"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Request-Context",
"value": "appId=cid-v1:04884d99-0742-441b-a23c-847133cb0130"
},
{
"key": "X-Robots-Tag",
"value": "noindex,nofollow"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "X-XSS-Protection",
"value": "1"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "Deny"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains"
},
{
"key": "Content-Security-Policy",
"value": "default-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: https://*.blob.core.windows.net https://*.amazonaws.com blob:;font-src 'self' data:;connect-src 'self' wss: https://sentry.io https://studio-feedback.azure-api.net https://storage.googleapis.com https://*.service.signalr.net https://*.blob.core.windows.net https://*.amazonaws.com dc.services.visualstudio.com;worker-src 'self' blob:"
},
{
"key": "X-Correlation-ID",
"value": "0ba95b3d-3dc2-4a8c-9160-a014ad0b48ac"
},
{
"key": "OData-Version",
"value": "4.0"
},
{
"key": "api-supported-versions",
"value": "12.0"
},
{
"key": "CF-Cache-Status",
"value": "DYNAMIC"
},
{
"key": "cf-request-id",
"value": "09901f22a800000fae6bb4e000000001"
},
{
"key": "Expect-CT",
"value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
},
{
"key": "Server",
"value": "cloudflare"
},
{
"key": "CF-RAY",
"value": "642d347ddb3b0fae-VIE"
},
{
"key": "Content-Encoding",
"value": "br"
}
],
"cookie": [
],
"body": "{\n \"@odata.context\": \"https://cloud.uipath.com/org/tenant/orchestrator_/odata/$metadata#Releases\",\n \"@odata.count\": 1,\n \"value\": [\n {\n \"Key\": \"ecde643a-3ec1-4a5c-b4ea-381759ee620a\",\n \"ProcessKey\": \"PetStore_UpdatePet\",\n \"ProcessVersion\": \"1.0.11\",\n \"IsLatestVersion\": false,\n \"IsProcessDeleted\": false,\n \"Description\": \"Blank Process\",\n \"Name\": \"Update existsing pet by ID\",\n \"EnvironmentId\": null,\n \"EnvironmentName\": \"\",\n \"EntryPointId\": null,\n \"InputArguments\": null,\n \"ProcessType\": \"Process\",\n \"SupportsMultipleEntryPoints\": true,\n \"RequiresUserInteraction\": true,\n \"AutoUpdate\": false,\n \"FeedId\": \"ef94e92f-5f58-474b-963c-c3ef46391ca7\",\n \"JobPriority\": \"Normal\",\n \"CreationTime\": \"2021-03-11T13:11:38.837Z\",\n \"OrganizationUnitId\": 515128,\n \"OrganizationUnitFullyQualifiedName\": \"UnattendedProcesses\",\n \"Id\": 30155,\n \"Arguments\": {\n \"Input\": \"[{\\\"name\\\":\\\"status\\\",\\\"type\\\":\\\"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\\",\\\"required\\\":false,\\\"hasDefault\\\":true}]\",\n \"Output\": null\n },\n \"ProcessSettings\": null\n }\n ]\n}"
}
]
}