Reputation: 677
I am trying to pass "test+data" to Retrofit api call but during api request process it is processing as "test%2Bdata". Due to this my API request is failing.
How to pass exact text to retrofit call?
i am trying with below code.
buildConfigField("String", "api_type", "\"test+data\"")
apiService.getAllData(BuildConfig.api_type)).enqueue(object : Callback<User> {
override fun onResponse(call: Call<User>, response: Response<User>) {
}
override fun onFailure(call: Call<User>, t: Throwable) {
}
});
@GET("/?format=json")
fun getAllData(@Query("q") q: String) : Call<User>
Upvotes: 0
Views: 252
Reputation: 188
You need to add 'encoded = true' to the @Query annotation, like this:
@Query("q" , encoded = true)
Upvotes: 1