Filter is ignored in odata/QueueItems

Hi Experts

I am trying to export the queue items from Orchestrator using odata/QueueItems in an Invoke-RestMethod in Powershell.

I can extract all the queue items but I would like to add a filter only returning queue items created after a specific date by using the following syntax:

odata/QueueItems?$filter=QueueDefinitionId eq 1234 and CreationTime gt 2022-11-01

But all queue items are returned regardless of the filter. I have tried with the following CreationTime as well:

odata/QueueItems?$filter=QueueDefinitionId eq 1234 and CreationTime gt 2022-11-01T00:00:00.000Z

NB! The queue definition ID in the above examples has been replaced with the actual ID.

This is a snippet of the script:

$queueItemHeader = @{‘X-UiPath-OrganizationUnitId’ = $queue.OrganizationUnitId ; ‘Accept’ = “*/*”; “Authorization” = $auth }
$queueItemResponse = Invoke-RestMethod -Method GET -Uri “$($orchestratorUri)/odata/QueueItems?$filter=QueueDefinitionId eq $($queue.Id) and CreationTime gt 2022-10-31” -Headers $queueItemHeader

The filtering works fine when using the Orchestrator HTTP Request activity. Any ideas of why it does not work in Powershell?

Rookie mistake! The $ needs to be escaped with a back tick since I am using double quotes to support Powershell variables.

The solution looks like this:

odata/QueueItems?`$filter=QueueDefinitionId eq 1234 and CreationTime gt 2022-11-01

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.