Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there any way to convert the response body to XML in flutter?

I have a get request in flutter, the response body comes as json, is there any way to have it in XML?
In the Swagger UI it comes as XML but I don’t know why it comes as Json in my request.
I am using this lines:

final response = await http.get(Uri.parse(selectedURL));
print(response.body);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You probably need to set the Accept header to something like:
Accept: application/xml

Something like this might do the trick:

final response = await http.get(
  Uri.parse(selectedURL),
  headers: {
    'Accept': 'application/xml',
  },
);
print(response.body);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading