Working with XML APIs and Converting Response to JSON
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Working with XML APIs and Converting Response to JSON
Hello - I'm a bit new to this, but I am working with an XML API.
Even when I set the "Response content type" to application/json, the response is still in XML. Is there a way I can ensure I will return JSON every time?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @nolandsmith
I am not sure why you can't get it.
Can you send your object description?
You can check this example:
1 - You declare your media types
2 - Then you check your object declaration
I took the petstore file example
I hope it can help 😏
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the support!
I don't even have application/xml as an applicable response content, yet it is still returning XML.
I do know that the API is an XML api (abr.business.gov.au/abrxmlsearch/abrxmlsearch.asmx/SearchByABNv202001). Could this be the reason I am only getting XML, or is there a way for Swagger to be able to return it as JSON?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@nolandsmith
I did some digging into your file and I did manage to generate a JSON response but ONLY as an example!!
Look at the file in attachement.
The sole response content type provided by the server is:
Content-Type: text/xml; charset=utf-8
and, I guess, this is the reason why it can't be displayed in JSON (message ref here)
Let us know if you find a solution
