Object instance NULL error

Hi everybody, Can someone please assist me here.


I’m getting this error on this activity:

,

So I am using the http activity there and the request comes back as this:


which is correct, so from the results from the http activity I am suppose to extract the word ‘complaints’ only but then using this assign activity to extract it:

It gives me the error above

Ensure the Assign Activity variable type matches the expected output:

  • If extracting a string, use String type.
  • If extracting a JObject or JArray, convert it using .ToString.
1 Like

try this
myJObject.SelectToken(“category”).ToString()

1 Like

@Anelisa_Bolosha1

Your myJObject variable is null due to this you are getting this error. Try debugging and check this variable value if holding something after Deserializing.

1 Like

Yes I have checked it, myJObject is null, returning nothing

Your code should work, check if string(API2) is not empty, you provided correct variable.
I tried same code it works

@Anelisa_Bolosha1,

Alright, to get the category you can use below code in assign activity which will deserialze the json and return you the value.

Category = Newtonsoft.Json.Linq.JObject.Parse(YourJsonText)("Category").ToString

1 Like

@adi.mehare Hi, this is strange now my API2(returned from http activity) is empty, but it wasn’t before :(…
and the email body I am using is not an empty body I Checked it:


This is the request I put in the API, then I replace ‘email_body’ with an actual email body from outlook and before I replace it I check it

I checked in postman, and it’s working well

@Anelisa_Bolosha1,

Put this part only in value side

Newtonsoft.Json.Linq.JObject.Parse(YourJsonText)("Category").ToString

1 Like

@Anelisa_Bolosha1

  1. First check if there are multiple variables created with same name in this could cause null reference issue…highlight the inner most activity and open variables panel to check the same
  2. From http request check if any value or anything is missing…better use breakpoint on http request then prrform step into and check the variable before and after step into in the locals panel…you would also get a chance to check the current values in http request in locals panel

Cheers

This is what comes in http,same as what i put on postman…but the results on http in UiPath returns nothing , status =500


I checked the variables, there is none that are the same.

Status : 500 means that error occurred at server side while processing your request.
If you are getting correct response using Postman but 500 using UiPath then you should verify that you have correctly configured your HTTP Request acclivity.

Hi everyone is there no other way of extracting the values from the JSON response without using Deserialization activity?:

It seems like it has a problem on my solution, down below I want to extract the values in orange:

Please assist on this

@Anelisa_Bolosha1,

String manipulation would an alternative option but couldn’t be reliable. JSON Deserialization is best suited here.

1 Like

Good day everyone, I think I know what could be a problem here, If you can see on the screenshot I sent here on how the body of the email is arranged written on each line of which it is suppose to be in one line else it will have an error, for example on postman:

All in one line

When in separate lines:
image

I want the email body to be in one line

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