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
- Lesson 169: Modifying Request URLs and Headers with OkHttp
- Lesson 97: Retrofit 2: Unit Testing with Mockito
- Lesson 83: Retrofit 2 – Using PATCH Requests to Update Portions of an Entity
- Lesson 80 – Retrofit 2: Enabling Offline Cache
- Lesson 78: Caching with Retrofit 2
- Lesson 76: Retrofit 2 – Issuing DELETE Requests
- Lesson 71 – Retrofit 2: Issuing PUT Requests to Update Entities
- Lesson 68: Retrofit 2 with RxJava
- Lesson 65: Retrofit 2 – POST Requests with @Body and @Field Params
- Lesson 64: Retrofit 2 – Configuring a HTTP Logging Interceptor
- Lesson 63 – Retrofit 2: Exploring Get Requests – @Query and @Path Parameters
- Lesson 60: Retrofit 2 Get Requests