I'm trying to get a location like this:
Retrofit (Interface)
@FormUrlEncoded @POST("/geolocation/v1/geolocate") Call<GetGeolocation> getLocation(@Field("key") String key); And here I appeal to him:
private Gson gson = new GsonBuilder().create(); private Retrofit retrofit = new Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create(gson)) .baseUrl("https://www.googleapis.com") .build(); private API api = retrofit.create(API.class); Call<GetGeolocation> googleLocation = api.getLocation("KEY"); googleLocation.enqueue(new Callback<GetGeolocation>() { @Override public void onResponse(Call<GetGeolocation> call, Response<GetGeolocation> response) { Log.d("Log:", "OK"); } @Override public void onFailure(Call<GetGeolocation> call, Throwable t) { Log.d("Log:", "Error"); } }); In response, I come
Response{protocol=h2, code=400, message=, url=https://www.googleapis.com/geolocation/v1/geolocate} On the other hand, I send the exact same request through Postman
https://www.googleapis.com/geolocation/v1/geolocate?key=KEY Everything comes to me correctly
Postman

Queryinstead ofField- YuriySPb ♦@FormUrlEncodedbesides query - YuriySPb ♦