Expected Object but received empty String in Json Response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2019 01:06 AM
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.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2019 01:53 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 03:38 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2019 06:21 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader