Unable to cast object of type 'newtonsoft.json.linq.jobject' to type 'system.string

When try to select an item M&E , i am getting an error " unable to cast object of type ‘newtonsoft.json.linq.jobject’ to type 'system.string"

This issue is causing only when i have Ambersent(&) in a list box.
Is there any way to select an item containing of ‘&’

Hi Satish,

Is it a web application you are trying to automate? And is the control a dropdown or listbox?
Could you please share the URL where you are trying to do this if you can? And please do share your xaml file.

We might try to use the HttpUtility.UrlDecode() Or URLEncode Method after checking what the values in the listbox or dropdown are.


Thank Amrita, I was able to figure workaround by replacing’&’ with ‘*’

1 Like

Hi @Amrita_Mogali

I have a similar problem. I am able to convert a JSON file to a data table using a local file (see attached “JSON to data table” but when I combine this approach with httpRequest, I get an error “Unable to cast object of type ‘Newtonsoft.Json.Linq.JProperty’ to type ‘Newtonsoft.Json.Linq.JObject’.”

Please will you advise what I am doing wrong.

httpRequest.xaml (11.7 KB)
json to data table.xaml (10.0 KB)inputJson.json (1.3 KB)

Your help would be greatly appreciated.


Hi Tobor,

In the httpRequest.xaml, in the for loop, you had incorrectly mentioned BdecJ as the collection to be iterated. I have changed it to BdecJ.Item(“results”). It now works correctly. I have attached the updated workflow for your reference. Hope this helps.

httpRequest.xaml (12.2 KB)


Hi @Amrita_Mogali

Thank you. That’s great.

Hi @Amrita_Mogali,

I’m also getting the same error when I try to pass variable in selector.
My problem statement is to click a date on a webpage which is dynamic (Date may change). I want whatever the user will enter, it will click on that date. So I have created a Demo project for that and passed a variable in the selector.

I’m attaching the workflow.

Main.xaml (12.7 KB)

Thanks & Regards,
Gunjan Bhogal

Hi @Amrita_Mogali,

Your help would be highly appreciable. Please let me know at the earliest.

Gunjan Bhogal



You cannot use directly genericValue types inside the selector.

You can either:

  • Change your variables type to “String” (simpler)
  • Inside your selector text, use mDate.Tostring and inside the Selector property, mSelector.Tostring



The value of mSelector is built incorrectly. You missed the single quotes of mDate. I have corrected it for you as below -

" <html title='Tiger Zinda Hai Movie, Showtimes in Pune &amp; Online Ticket Booking' /><webctrl aaname='*"+mDate+"*' parentid='showDates' tag='DIV' /> "


Thank you @Amrita_Mogali and @Florent_Salendres.

I was able to build selector using a variable with you help, but I had to change the format of mDate in the selector as ‘“+mDate.toString+”

Gunjan Bhogal

Hi Amrita ,

I am getting the below exception for Deserialize json activity in uipath , the same use to work fine earlier but now i am getting this error , can you please help me with this
Message: Method ‘Newtonsoft.Json.Linq.JToken get_Item(System.String)’ declared on type ‘Newtonsoft.Json.Linq.JObject’ cannot be called with instance of type ‘Newtonsoft.Json.Linq.JObject’

Exception Type: ArgumentException



I may have found of cause of such exception. Did you ever install any custom packages that contains any Newtonsoft.Json references?

This may have caused some issue. Once I have un-install my custom package that references the Newtonsoft.Json dll, I can now retrieve JSON value as normal.

I’m facing the same problem with deserialize json object/array.

Here are the json file (I hope the format is correct…) and the workflow I made.
config.json (21 Bytes)
1.1.loadConfig.xaml (8.0 KB)
I first tried with arguments and then variables but naturally it didn’t make any difference.
Aslo tried uninstalling all the activity packages, but it did not help either.

config.json (101 Bytes)
1.1.loadConfig.xaml (8.1 KB)

Now this works.
Seems like the “¥” I put in the json file was one of the problems I had.

I am trying to pass dynamic value in selector for selecting column name, using input dialog box. But, when I am trying to pass I am getting exception: Invalid Cast Exception

My Selector is : “<webctrl parentid=‘logout’ tableCol=”+dropDate+“tag=‘IMG’ />” Where dropDate is the output I am getting from input dialog box.

Hey @Anchal_Sarraf

What kind of datatype of your passed Input box output argument?

you can use like this:

“<webctrl parentid=‘logout’ tableCol='”+dropDate.Tostring+“' tag=‘IMG’ />”.


I am not able to upload my .xaml file, as I am a new user. Is there a way to do that?

TransportDropAutomation.xaml (22.0 KB)

Hello Akash,

I am facing the issue at “Click ‘A logout’” activity.

Anchal Sarraf

TransportDropAutomation.xaml (21.9 KB)
I just made the changes what @aksh1yadav told.
Try if this works and please let me know if it did!