Inside my Android kotlin app i'm calling some apis by using retrofit2 like
@FormUrlEncoded
@POST("something/some")
fun callMyApi(
@Field("myField") myField: String
): Deferred<MyResponseClass>
Now i need to add some common post params to all my api request (and keep the specific ones for each call, in this case i need to keep "myField"), so i'm using an interceptor:
val requestInterceptor = Interceptor { chain ->
val newRequest = chain.request()
.newBuilder()
.post(
FormBody.Builder()
.add("common1Key", "common1")
.add("common2Key", "common2")
.add("common3Key", "common3")
.build()
)
.build()
return@Interceptor chain.proceed(newRequest)
}
But this implementation fails because the interceptor seems to overwrite myField. How can i fix it?