Deserialize Json is not working

Hi

when i am working on deserialize json, i got below exception

Main has thrown an exception

Source: For each

Message: Unable to cast object of type ‘Newtonsoft.Json.Linq.JProperty’ to type ‘Newtonsoft.Json.Linq.JObject’.

Exception Type: InvalidCastException

System.InvalidCastException: Unable to cast object of type ‘Newtonsoft.Json.Linq.JProperty’ to type ‘Newtonsoft.Json.Linq.JObject’.
at UiPath.Core.Activities.ForEach 1.InternalExecute(NativeActivityContext context, IEnumerator valueEnumerator) at UiPath.Core.Activities.ForEach 1.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

My xamlproject.json (292 Bytes)
Main.xaml (8.4 KB)

Can you please and let me know where i am doing wrong

Hello @Raghuveerk,

I have run your code (with the Http request commented, I have used the following Json String: {“C1-AddCase”:“dddd”,“C3-AddCase”:“ffff”}) and it works, I cannot reproduce your problem.

If your error continues the message is quite clear: Unable to cast object of type ‘Newtonsoft.Json.Linq.JProperty’ to type ‘Newtonsoft.Json.Linq.JObject’ so you have to change Type Argument property of the for each activity.

Can you share an example of your json? Could it be a JArray?

Best Regards,
Susana

Hi Susana

Here is the Json response which i will be using in bodyDto
{“C1-AddCase”:{“caseId”:“2372830075”,“caseType”:“OUTAGE”,“user”:“SYSUSER”,“status”:“NEW”,“condition”:“OPEN”,“characteristic”:{“characteristics”:{“characteristicType”:“CBN”,“sequence”:“1”,“adhocCharacteristicValue”:“87329784534623”}}}}