I am using a base URL like below
private const val BASE_URL = "anyURL"
an htt*P client
private val client = OkHtttpClient.Builder().apply {
addInterceptor(MyInterceptor())
}.build()
a retrofit client
private val retrofit = Retrofit.Builder()
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.client(client)
.baseUrl(BASE_URL).build()
and a get call
@GET("playlist_tracks=*********")
suspend fun geAlltracks(): Music
Currently, I am using an interceptor, but how can append my request with headers without Interceptor

Rajkiran SwainPosted Mar 30, 2023, 6:32 AM
You can append headers in Retrofit API call without using an Interceptor by creating a custom OkHttpClient with headers and using it to build the Retrofit instance. Here is an example of how you can do that:
In this way, the custom OkHttpClient will automatically append the headers to every API call made by the Retrofit instance.