Hi All, I am trying to read json response received from HTTP Request activity. I am using for each loop to get data after deserialize the data and store it to JObject Variable. After executing I am getting error "For Each: Object reference not set to an instance of an object. I am pasting Json Body as below in which I am trying to fetch all data within “RPAVcatEntitiesList”.
@shekharhimanshu627, this error means your JObject Variable is null. Check if you have passed this variable to output property of Deserialize JSON activity.
Null Reference: Ensure the JSON structure matches the provided example and the keys are correctly referenced.
Type Argument: Set the “Type Argument” of the “For Each” loop to JToken to correctly handle the items in the JSON array.
Empty Array: If the JSON array is empty, ensure your workflow can handle this scenario gracefully.
To address the error “For Each: Object reference not set to an instance of an object” in UiPath, ensure that the JSON structure is correctly parsed and that the “RPAVcatEntitiesList” array is correctly accessed. Below is a step-by-step solution to parse the given JSON response and iterate through the “RPAVcatEntitiesList” array:
Assign JSON Response: Ensure that you have assigned the JSON response to a string variable (e.g., jsonResponse).
Deserialize JSON: Use the “Deserialize JSON” activity to convert the JSON string into a JObject variable (e.g., jObject).
Extract Data: Use a “For Each” loop to iterate through the “RPAVcatEntitiesList” array within the JObject.