REST API Response format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2018 11:18 PM
Hi All,
I am working on an integration. i have to use GET method.
I have an api end point with method get which only return in the format of XML only. I am only supposed to use REST.
How can i convert the XML to a table in servicenow effectively. I am not to use SOAP.
Thanks,
Abhi
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 02:04 AM
Hi Abhinab,
So what is your question now?
you are getting response in xml, you are not facing any issue in parsing xml.
Regards
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
11-09-2018 01:52 AM
Hi Abhinab,
You can refer the below link for parsing the XML response:
if you are working on scoped application then you can refer the below link:
Please mark this solution correct/helpful, if it resolves your issue.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 02:15 AM
But i need to convert this to json as wrking on xml is very tedious.. so baiscally i want to covert that xml to json
i have already converted the xml to string and getting the nodes but , i want to convert that to complete json format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 02:21 AM
Hi Abhinab,
When you are consuming the 3rd party API can you set the http header as below:
Accept: application/json
May be this will try to give you json response in the body.
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
11-09-2018 02:31 AM
Hi Abhinab,
Then I think you can check for some solution on internet. I haven't done this before. But I would like to share a thought
If you convert your entire XML response in Json and then read the data. you might need to store the XML response and then the JSON you got by converting the XML to JSON. because you will need these to troubleshoot the issue in future. Because error occur because of the following:
1) due to the data returned in XML response OR (so you need to store XML response)
2) there might be issue in converting XML to JSON OR (so you need to store JSON converted data to check if data was parsed correctly from XML to JSON)
3) there might be issue while reading the data from JSON.
think about this once before implementing.
Thanks.