我需要获取“产品”数据。当我得到response.message()时,它返回“ok”,但我查找的数据不是。 API网址格式如下:http://webhose.io/productFilter?token=789536e4-000d-4a3a-a7ac-223634f596 **& format = json& q = in_stock%3Atrue
我的问题是'%3A' 在代码中使用':'而不是'%3A'是必要的 谢谢你的帮助。
Products.java
interface Products {
@GET("{typefilter}")
Call<Result> getProducts(@Path("typefilter") String typefilter, @Query("token") String token,
@Query("format") String format, @Query("q") String filter);
}
Activity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Service.Products service = Client.getClient().create(Service.Products.class);
Call<Result> call = service.getProducts("productFilter",
"789536e4-000d-4a3a-a7ac-223634f596**","json","in_stock%3Atrue");
call.enqueue(new Callback<Result>() {
@Override
public void onResponse(Call<Result> call, Response<Result> response) {
Result result = response.body();
Log.d("Result", response.message());
Log.d("Result", result.getNext());
Log.d("Result","quantity:" +result.getProducts().length);
}
@Override
public void onFailure(Call<Result> call, Throwable t) {
}
});
}