Retrofit 2 — Send JSON Requests and Receive XML Responses (or vice versa)

In most cases, your app will send and receive all server data in the same data format. For example, if you interact with the GitHub API, you'll send and receive JSON. Nevertheless, Retrofit is quite flexible in its design and allows support for multiple data formats at the same time, as we've described in the tutorial about supporting JSON and XML responses concurrently.

In this tutorial, we'll go one step further and show how you can send data in one format and receive it in another format! Specifically, we'll send a JSON request and receive an XML response. The approach is general, so it'd also work for any other combination of data formats.

Retrofit Series Overview


Continue reading

University Enrollment Required

Future Students benefit from value packed videos and tutorials.

Enroll to receive exclusive content or sign in if you’re already a Future Student.

Enroll me for $15/mo

Explore the Library

Find interesting tutorials and solutions for your problems.

Miscellaneous