Reputation: 159
//url to consume - baseURL/xyz/test-map.php?key=3ec9864e9db5fb47da338d108503d4612fc65b80
@FormUrlEncoded
@POST("xyz/test-map.php")
Call<Root> getResponseForApi (@Field(value = "key", encoded = true) String key ,
@Field("auth_key") int auth_key,
@Field("password") int password) ;
when i try to call ,
Call<Root> call = apiServiceImplementation.getResponseForApi(key, auth_key, password);
call.enqueue(new Callback<Root>() {
@Override
public void onResponse(Call<Root> call, Response<Root> response) {
Root data = response.body();
}
@Override
public void onFailure(Call<Root> call, Throwable t) {
Log.e("TAG", "onFailure: " );
}
});
i am getting URL in on response as without query parameter like "baseURL/xyz/test-map.php
" only.
why it is not encoding
Upvotes: 0
Views: 382
Reputation: 1278
you can use both @Query and @Field in your request. here is your solution.
@FormUrlEncoded
@POST("xyz/test-map.php")
Call<Root> getResponseForApi (@Query("key") String key ,
@Field("auth_key") int auth_key,
@Field("password") int password) ;
Upvotes: 4