Unable to cast object of type 'Newtonsoft.Json.Linq.JProperty' to type 'Newtonsoft.Json.Linq.JObject' error in uipath

Dear All,

While running the below code, i am getting Unable to cast object of type ‘Newtonsoft.Json.Linq.JProperty’ to type ‘Newtonsoft.Json.Linq.JObject’ error. Please suggest hot to resolve the issue.DataExtraction - ML Extractor(Updated).zip (99.3 KB)

can you try to change the type of the argument, your passing string as a input to that activity, so it may resolve the issue

Hi @Anamika15,
Could you please try by changing for each object type to “Newtonsoft.Json.Linq.JToken” and use item.ToString instead of item(“DocumentId”).ToString.

Hope this will work for you.
Thank you!

Changing object type to “Newtonsoft.Json.Linq.JToken” is partially solving the issue. Now I am not getting error but its giving me complete JSON file in message box.
I need few elements only. Document id, invoice id etc. Any idea how to get this?

Thanks for the response.
Changing type of argument is giving error. Its accepting only Object type.

Add simple condition inside as below.
If item.ToString.contains(“DocumentId”)
Then split it accordingly to get the exact value.