Chilkat Online Tools

SQL Server / Orchestrator API Documentation / Get Queue Item by ID

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
    -- 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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    -- 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 @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://domain.com/odata/QueueItems({{queueItemId}})', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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 @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

    -- Sample JSON response:
    -- (Sample code for parsing the JSON response is shown below)

    -- {
    --   "@odata.context": "https://cloud.uipath.com/org/tenant/orchestrator_/odata/$metadata#QueueItems/$entity",
    --   "QueueDefinitionId": 28211,
    --   "OutputData": null,
    --   "AnalyticsData": null,
    --   "Status": "New",
    --   "ReviewStatus": "None",
    --   "ReviewerUserId": null,
    --   "Key": "883749b2-70cd-4beb-b0a7-4fd260d26635",
    --   "Reference": "Petstore",
    --   "ProcessingExceptionType": null,
    --   "DueDate": "2021-03-11T15:19:56.44Z",
    --   "RiskSlaDate": null,
    --   "Priority": "Normal",
    --   "DeferDate": "2021-03-11T14:19:56.44Z",
    --   "StartProcessing": null,
    --   "EndProcessing": null,
    --   "SecondsInPreviousAttempts": 0,
    --   "AncestorId": null,
    --   "RetryNumber": 0,
    --   "SpecificData": "{\"DynamicProperties\":{\"Name\":\"Testymonika2000\"}}",
    --   "CreationTime": "2021-03-31T12:55:21.783Z",
    --   "Progress": null,
    --   "RowVersion": "AAAAAAbEaR8=",
    --   "OrganizationUnitId": 515128,
    --   "OrganizationUnitFullyQualifiedName": null,
    --   "Id": 45403309,
    --   "ProcessingException": null,
    --   "SpecificContent": {
    --     "Name": "Testymonika2000"
    --   },
    --   "Output": null,
    --   "Analytics": null
    -- }

    -- Sample code for parsing the JSON response...
    -- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    DECLARE @odata_context nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @odata_context OUT, '"@odata.context"'
    DECLARE @QueueDefinitionId int
    EXEC sp_OAMethod @jResp, 'IntOf', @QueueDefinitionId OUT, 'QueueDefinitionId'
    DECLARE @OutputData nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @OutputData OUT, 'OutputData'
    DECLARE @AnalyticsData nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @AnalyticsData OUT, 'AnalyticsData'
    DECLARE @Status nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'Status'
    DECLARE @ReviewStatus nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ReviewStatus OUT, 'ReviewStatus'
    DECLARE @ReviewerUserId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ReviewerUserId OUT, 'ReviewerUserId'
    DECLARE @Key nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Key OUT, 'Key'
    DECLARE @Reference nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Reference OUT, 'Reference'
    DECLARE @ProcessingExceptionType nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ProcessingExceptionType OUT, 'ProcessingExceptionType'
    DECLARE @DueDate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @DueDate OUT, 'DueDate'
    DECLARE @RiskSlaDate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @RiskSlaDate OUT, 'RiskSlaDate'
    DECLARE @Priority nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Priority OUT, 'Priority'
    DECLARE @DeferDate nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @DeferDate OUT, 'DeferDate'
    DECLARE @StartProcessing nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @StartProcessing OUT, 'StartProcessing'
    DECLARE @EndProcessing nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @EndProcessing OUT, 'EndProcessing'
    DECLARE @SecondsInPreviousAttempts int
    EXEC sp_OAMethod @jResp, 'IntOf', @SecondsInPreviousAttempts OUT, 'SecondsInPreviousAttempts'
    DECLARE @AncestorId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @AncestorId OUT, 'AncestorId'
    DECLARE @RetryNumber int
    EXEC sp_OAMethod @jResp, 'IntOf', @RetryNumber OUT, 'RetryNumber'
    DECLARE @SpecificData nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @SpecificData OUT, 'SpecificData'
    DECLARE @CreationTime nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @CreationTime OUT, 'CreationTime'
    DECLARE @Progress nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Progress OUT, 'Progress'
    DECLARE @RowVersion nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @RowVersion OUT, 'RowVersion'
    DECLARE @OrganizationUnitId int
    EXEC sp_OAMethod @jResp, 'IntOf', @OrganizationUnitId OUT, 'OrganizationUnitId'
    DECLARE @OrganizationUnitFullyQualifiedName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @OrganizationUnitFullyQualifiedName OUT, 'OrganizationUnitFullyQualifiedName'
    DECLARE @Id int
    EXEC sp_OAMethod @jResp, 'IntOf', @Id OUT, 'Id'
    DECLARE @ProcessingException nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @ProcessingException OUT, 'ProcessingException'
    DECLARE @Name nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'SpecificContent.Name'
    DECLARE @Output nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Output OUT, 'Output'
    DECLARE @Analytics nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Analytics OUT, 'Analytics'

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
	-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
https://domain.com/odata/QueueItems({{queueItemId}})

Postman Collection Item JSON

{
  "name": "Get Queue Item by ID",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "//test status code\r",
          "pm.test(\"Status code is 200\", function () {\r",
          "    pm.response.to.have.status(200);\r",
          "});\r",
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "Folder/OrganizationUnit Id",
        "key": "X-UIPATH-OrganizationUnitId",
        "value": "{{folderId}}"
      }
    ],
    "url": {
      "raw": "{{url}}/odata/QueueItems({{queueItemId}})",
      "host": [
        "{{url}}"
      ],
      "path": [
        "odata",
        "QueueItems({{queueItemId}})"
      ],
      "query": [
        {
          "key": "$expand",
          "value": "",
          "description": "Indicates the related entities to be represented inline. The maximum depth is 2.",
          "disabled": true
        },
        {
          "key": "$select",
          "value": "",
          "description": "Limits the properties returned in the result.",
          "disabled": true
        }
      ]
    },
    "description": "OAuth required scopes: OR.Queues or OR.Queues.Read.\r\n\r\nRequired permissions: Queues.View and Transactions.View."
  },
  "response": [
    {
      "name": "Get Queue Item by ID",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Folder/OrganizationUnit Id",
            "key": "X-UIPATH-OrganizationUnitId",
            "value": "{{folderId}}"
          }
        ],
        "url": {
          "raw": "{{url}}/odata/QueueItems({{queueItemId}})",
          "host": [
            "{{url}}"
          ],
          "path": [
            "odata",
            "QueueItems({{queueItemId}})"
          ],
          "query": [
            {
              "key": "$expand",
              "value": "",
              "description": "Indicates the related entities to be represented inline. The maximum depth is 2.",
              "disabled": true
            },
            {
              "key": "$select",
              "value": "",
              "description": "Limits the properties returned in the result.",
              "disabled": true
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Wed, 31 Mar 2021 12:55:30 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": "b293055b-0924-4b58-bcaf-c4e6c7622b30"
        },
        {
          "key": "OData-Version",
          "value": "4.0"
        },
        {
          "key": "api-supported-versions",
          "value": "12.0"
        },
        {
          "key": "CF-Cache-Status",
          "value": "DYNAMIC"
        },
        {
          "key": "cf-request-id",
          "value": "0929f383d20000cba029166000000001"
        },
        {
          "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": "6389bb7fbf77cba0-VIE"
        },
        {
          "key": "Content-Encoding",
          "value": "br"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"@odata.context\": \"https://cloud.uipath.com/org/tenant/orchestrator_/odata/$metadata#QueueItems/$entity\",\n    \"QueueDefinitionId\": 28211,\n    \"OutputData\": null,\n    \"AnalyticsData\": null,\n    \"Status\": \"New\",\n    \"ReviewStatus\": \"None\",\n    \"ReviewerUserId\": null,\n    \"Key\": \"883749b2-70cd-4beb-b0a7-4fd260d26635\",\n    \"Reference\": \"Petstore\",\n    \"ProcessingExceptionType\": null,\n    \"DueDate\": \"2021-03-11T15:19:56.44Z\",\n    \"RiskSlaDate\": null,\n    \"Priority\": \"Normal\",\n    \"DeferDate\": \"2021-03-11T14:19:56.44Z\",\n    \"StartProcessing\": null,\n    \"EndProcessing\": null,\n    \"SecondsInPreviousAttempts\": 0,\n    \"AncestorId\": null,\n    \"RetryNumber\": 0,\n    \"SpecificData\": \"{\\\"DynamicProperties\\\":{\\\"Name\\\":\\\"Testymonika2000\\\"}}\",\n    \"CreationTime\": \"2021-03-31T12:55:21.783Z\",\n    \"Progress\": null,\n    \"RowVersion\": \"AAAAAAbEaR8=\",\n    \"OrganizationUnitId\": 515128,\n    \"OrganizationUnitFullyQualifiedName\": null,\n    \"Id\": 45403309,\n    \"ProcessingException\": null,\n    \"SpecificContent\": {\n        \"Name\": \"Testymonika2000\"\n    },\n    \"Output\": null,\n    \"Analytics\": null\n}"
    }
  ]
}