Getting Error in -> For Each currentQueueItem: Object reference not set to an instance of an object

Hi All,

I’m trying to Get Queue items information (with its status and other details), but I’m getting error as :

For Each currentQueueItem: Object reference not set to an instance of an object.

Kind Note: When I’m running the code in Dev tenant it’s working completely fine, but in “Test tenant” it’s throwing me the above error.

Tried:
→ Connected with the right Test tenant (Orch. URL)
→ Connected with the right Test folder name
→ Am able to add Queue items in Test and status of the items is also converting from New to Successful.

image

  • Is it the connectivity or configurable issue?

Please let me know if anyone can help me with this issue.

BR,
NK

Hi @Nitesh,

This usually happens when variable being referenced is not initialized(no value).

Can you please verify below:

  1. the output variable of get items is the one you are using in for each
  2. also it can be the case that queue doesn’t have any items matching the search criteria that you have set.

Do a manual check as well on the queue in orchestrator to see if there are any items matching your search criteria.

To mitigate this, you can do like below:
Before running the loop, include a count check on the output variable being returned by Get queue items activity.
And if count>0 then only traverse through loop.

Regards
Sonali

1 Like

**Update:

Hi,

I realized, it is working fine if I remove “To” field from the Get Queue Items property.

But I want to use this as I want to fetch the data which is of current date.
Tried using DateTime.Now but it throws me now with the below error:
Get Queue Items: Invalid OData query options. Error code: 1000

image

NOTE:
->I have 6 items added in the Queue with “Successful” status and I am trying to fetch information from those. So count it should give me as 6 but its showing me 0 but if I remove “To” field from the Get Queue Items property it works fine.

→ Same code its working fine in Dev.

BR,
NK

Hi @Nitesh
Use ‘Today’ in the ‘From’ property to retrieve the items for the day.
The issue is that DateTime.Now or DateAndTime.Now returns the current hours/minutes/seconds which means there are not items created at the runtime time; instead ‘Today’ will filter the items for the specific day 01/09/2025 “without time”

1 Like

Hi @Eric_Alvarado ,

After using Today function in “From” field, I am receiving the below error:

image

Note: Tried in “To” field as well.

BR,
NK

Hi @Nitesh,

I think it’s happening because format has to be datetime.

Try this:

Cdate(Now.ToString(“MM/dd/yyyy 00:00:00”))

Regards
Sonali

Hi @sonaliaggarwal47 ,

Below error is displayed after trying above in the From field:

image

BR,
NK

@Nitesh

You can also give a try for below:

DateTime.Now().Date

Regards
Sonali

Oh this is just because of double quotes. Remove those double quotes and type it again, it will go away

Tried below:

image

Error:
Get Queue Items: Invalid OData query options. Error code: 1000

And tried removing double quotes: it suggests syntax error.

I meant, remove and re-enter double quotes.

This issue happens when double quotes were entered in some other application and copy pasted hence sometimes not recognizable by UiPath.

But it needs to be provided.

For this, try below:

Now.Date

Dear @Nitesh

Kindly use below format and assign to a variable. Use the same as expression

Tested and working fine for me. Let us know if you are facing issue

1 Like

Hi @sharazkm32 ,

I tried above (in From field) with dtime = Cdate(DateTime.Now.ToString(“M/d/yyyy”)) with datatype as System.DateTime and it thrown below error in Get Queue Items activity:

image

BR,
NK

@sonaliaggarwal47
Same Error

Get Queue Items: Invalid OData query options. Error code: 1000

Hi @Nitesh,

By any chance, are you using queue reference while adding items to the queue?

That is also one way - like I mostly use reference as some unique id of queue prefixes/suffixes by date time.

So if you also use something like that, that reference section under properties can also be used to filters your queue items.

Also did you get a chance to replace the double quotes in below query and use it?

Cdate(Now.ToString(“MM/dd/yyyy 00:00:00”))

Regards
Sonali

Thanks guys for your quick response, but I figured out the solution with my existing code as DateAndTime.Now in “To” field of Get Queue Items.

I forgot that I didn’t disabled the API settings in my Test server like I did in Dev server. That’s why same code was working fine in Dev but not in Test.

Solution:

After I disabled the API settings from orchestrator (Test tenant), it worked.

  1. Navigate to Orchestrator> Tenant > Settings > General.
  2. Scroll down to “API Settings” and disable the checkbox selected.
  3. Save the configurations.

This solution has been provided in below thread as well.

Get queue items returns error “Invalid odata query options code 1000” - Help / Activities - UiPath Community Forum

BR,
NK

4 Likes

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