Making REST calls in Kotlin Android using OKHTTP and Coroutines
9 min readDec 26, 2021
Photo by Pineapple Supply Company on Unsplash
Here a quick Kickstart Tutorial for making REST calls with OkHttp and Kotlin Coroutines in your Android app.
This tutorial will provide step-by-step instructions on:
- Configuring your app for making REST calls
- Using OkHttp to make a Get call
- Launch a Get request from a background thread
- Use ViewModel and LiveData to update the UI.
Please ‘follow me’ on Medium if you like this post.
1. Versions used
- Android Studio 4.1.1
- Android API 29
- OkHttp 4.9.0
- view model and livedata 2.2.0
- klaxon 5.0.1
2. Creating a project
First, let’s create a new project using the ‘Basic Activity’ template. In Android Studio, select the ‘File’ menu, ‘New Project’ menu item.
Select ‘Next’.