Yandex Maps使用改装返回403 Forbidden



当我调用此链接时https://geocode-maps.yandex.ru/1.x/?format=json&geocode=astana在我的浏览器上,它可以工作,但当我使用改装调用它时,它给了我403禁止的

我的代码是

Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(Settings.YANDEX_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .client(client)
            .build();
    return retrofit.create(YandexService.class);
public final static String YANDEX_URL = "https://geocode-maps.yandex.ru/1.x";

我用这个称之为

@GET("/")
Call<YandexResponse> getGeoCollection(@Query("format") String format, @Query("geocode") String geocode);

和这个

@Override
public void getMapLocation() {
    Call<YandexResponse> call = dataProvider.yandexSearch("Astana");
    call.enqueue(new Callback<YandexResponse>() {
        @Override
        public void onResponse(Response<YandexResponse> response, Retrofit retrofit) {
        }
        @Override
        public void onFailure(Throwable t) {
            Alert.showDefaultAlert(baseActivity);
            t.printStackTrace();
        }
    });
}

为什么它给我403禁言,它不需要任何授权。。。

I只需将/1.x/从YANDEX_URL粘贴到服务

成为这个

public final static String YANDEX_URL = "https://geocode-maps.yandex.ru";
@GET("/1.x/")
Call<YandexResponse> getGeoCollection(@Query("format") String format, 
                                      @Query("geocode") String geocode);

最新更新