The CreatorCon Call for Content is officially open! Get started here.

Expected Object but received empty String in Json Response

Avinash30
Kilo Explorer

Hi All ,

I am currently working on an integration software and trying to fetch ServiceNow incidents using rest api ; /api/now/v1/table/incident .

There is a field in the JSON response which looks like following :

"u_owner_mi": {
"link": "https://yyyyyyy.service-now.com/api/now/v1/table/sys_user/xxxxxxxx",
"value": "xxxxxxxx"
},

But the problem is sometimes when the "u_owner_mi" is not set , it is returning "" ; which is an empty String and not object. I am working on Android Application and using gson and retrofit to fetch this data.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Avinash,

So if the value is not present in that then it would return empty string that is out of box servicenow behavior I think which could not be changed.

Can you have your code check whether object is present in the response; if object is present value is there; if it is a string then value not present

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur,

I'm working on similar sort of requirement, where the field in the table is reference type and whenever the field is empty, it is returning an empty string " ".
Is it possible to hide that field whenever there is no value?

 

Regards,

Namrata

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Avinash,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader