Retrofit & REST
DATA › Networking
Drills wiring Retrofit, REST verbs and annotations, converters, suspend error handling, and resilient retries.
Retrofit is the de facto networking layer in modern Android, so interviewers probe whether you can wire it cleanly and handle real-world failures, not just the happy path. Expect questions on suspend-based calls, Response<T> versus returning the body directly, converter choice, and turning raw responses into a typed sealed Result. Knowing REST semantics and a sane retry/backoff policy is what separates seniors from juniors.
What this covers
- Configuring Retrofit.Builder: baseUrl (trailing slash), converter factories, OkHttpClient, and URL resolution rules
- HTTP method annotations (@GET/@POST/@PUT/@DELETE/@PATCH) and parameter annotations (@Path, @Query, @Body, @Field, @Header)
- Choosing and wiring converters: kotlinx.serialization vs Moshi/Gson
- suspend functions vs Call<T>, and Response<T> error handling (isSuccessful, body, errorBody, HttpException)
- REST semantics: safe vs idempotent methods and common status codes
- Modelling outcomes with a sealed Result<T> and implementing an exponential-backoff retry strategy
Study this topic
- Retrofit & REST explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Retrofit & REST interview questions and answers