Retrofit 2 — Handling of Empty Server Responses with Custom Converter

Some APIs return an empty response body to signal the client that there is no object. Retrofit's converters can trip over that, because it can be an invalid representation in their respective data format. For example, an empty object needs to be {} in JSON.

In this tutorial you'll learn how you can handle these empty server responses. We'll show you an example of treating them as valid null objects.

Retrofit Series Overview

  1. Introduction to Call Adapters (Coming soon)
  2. Custom Call Adapter to Separate OnResponse Callback (Coming soon)
  3. How to Integrate RxJava 1.x Call Adapter (Coming soon)
  4. How to Integrate RxJava 2.x Call Adapter (Coming soon)
  5. How to Integrate Guava Call Adapter (Coming soon)
  6. Custom Call Adapter to Separate Network and Gson Errors (Coming soon)
  1. Callbacks (Coming soon)
  2. Annotations (Coming soon)
  3. Fluent Interface with Builders (Coming soon)


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 $12/mo

Explore the Library

Find interesting tutorials and solutions for your problems.

Miscellaneous