Retrofit and GET using parameters

前端 未结 4 1303
时光取名叫无心
时光取名叫无心 2020-12-02 16:07

I am trying to send a request to the Google GeoCode API using Retrofit. The service interface looks like this:

public interface FooService {    
    @GET(\"         


        
4条回答
  •  无人及你
    2020-12-02 16:58

    AFAIK, {...} can only be used as a path, not inside a query-param. Try this instead:

    public interface FooService {    
    
        @GET("/maps/api/geocode/json?sensor=false")
        void getPositionByZip(@Query("address") String address, Callback cb);
    }
    

    If you have an unknown amount of parameters to pass, you can use do something like this:

    public interface FooService {    
    
        @GET("/maps/api/geocode/json")
        @FormUrlEncoded
        void getPositionByZip(@FieldMap Map params, Callback cb);
    }
    

提交回复
热议问题