A Lesson by Annyce Davis
This lesson is part of the Retrofit course.
In this lesson we’ll review how to modify your Retrofit 2 requests using OkHttp. Retrofit ships with the ability to add headers to individual requests. However, if you want to add headers to every request, then it’s recommended that you use an OkHttp Interceptor.
In this lesson you will learn:
- What a network interceptor is
- What an application interceptor is
- How to add an application interceptor to add a header value
- How to add an application interceptor to add a query string parameter
Code for the Lesson
Pro members: Log in to view the code for this lesson!
Lessons in the Retrofit 2 Course
- Modifying Request URLs and Headers with OkHttp
- Retrofit 2: Unit Testing with Mockito
- Retrofit 2 – Using PATCH Requests to Update Portions of an Entity
- Retrofit 2: Enabling Offline Cache
- Caching with Retrofit 2
- Retrofit 2 – Issuing DELETE Requests
- Retrofit 2: Issuing PUT Requests to Update Entities
- Retrofit 2 with RxJava
- Retrofit 2 – POST Requests with @Body and @Field Params
- Retrofit 2 – Configuring a HTTP Logging Interceptor
- Retrofit 2: Exploring Get Requests – @Query and @Path Parameters
- Retrofit 2 Get Requests