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.
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 😏
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?
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