I am trying with Hilt and Retrofit2 to create a Post request with a dynamic URL.
I am getting the error @Url cannot be used with @POST URL (parameter #1)
I need the query to be dynamic too
@POST("{id}")
suspend fun getConfiguration(
@Url url: String,
@Body configRequest: ConfigRequest,
@Query("id") id: String
): Config
the builder
@ExperimentalSerializationApi
@Provides
@Singleton
fun provideApi(@ApplicationContext context: Context): Api{
val contentType = "application/json".toMediaType()
val json = Json {
explicitNulls = false
coerceInputValues = true
ignoreUnknownKeys = true
}
return Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.client(RetrofitHelper.getOkHttpClient(context))
.addConverterFactory(json.asConverterFactory(contentType))
.build()
.create(Api::class.java)
}
Any work arounds?