我正在尝试使用Retrofit 2调用遗留API,这是URL "/api/0.3/v3/?endpoint=/admin/customers/6728382/addresses.json"
,这是接口方法
@GET("/api/0.3/v3/?endpoint=/admin/customers/{customerId}/addresses.json")
Single<GetCustomerAddressesResponse> getUserAddresses(@Path("customerId") String customerId);
但是我收到了这个错误,
“网址查询字符串 “endpoint = // admin / customers / {customerId} /addresses.json”必须没有 替换块。对于动态查询参数,请使用@Query。“
我该如何解决这个问题?
答案 0 :(得分:0)
我认为int
必须是String
类型。尝试将int
更改为{{1}}。
答案 1 :(得分:0)
&#34; URL查询字符串&#34; endpoint = // admin / customers / {customerId} /addresses.json"一定不能有替换块。对于动态查询参数,请使用@Query。&#34;
建议您使用@Query
代替@Path
。
Single<GetCustomerAddressesResponse> getUserAddresses(@Query("customerId") String customerId);
您可能希望详细了解@Query
注释https://square.github.io/retrofit/2.x/retrofit/index.html?retrofit2/http/Query.html