Part 2: Sending Data With Retrofit 2 HTTP Client for Android

Part 2: Sending Data With Retrofit 2 HTTP Client for Android

What Is Retrofit?

Retrofit is a type-safe HTTP client for Android and Java. Retrofit makes it easy to connect to a REST web service by translating the API into Java interfaces. In this tutorial, I’ll show you how to use one of the most popular and often recommended HTTP libraries available for Android.

So Why Use Retrofit?

Developing your own type-safe HTTP library to interface with a REST API can be a real pain: you have to handle many aspects, such as making connections, caching, retrying failed requests, threading, response parsing, error handling, and more. Retrofit, on the other hand, is a well-planned, documented and tested library that will save you a lot of precious time and headaches.

In this tutorial, I will explain how to use Retrofit 2 to handle network requests by building a simple app that will perform POST requests, PUT requests (to update entities), and DELETE requests. I’ll also show you how to integrate with RxJava and how to cancel requests. We’ll be using the API provided by JSONPlaceholder—this is a fake online REST API for testing and prototyping.

Continue to read the full tutorial at Tuts+