I'm using Retrofit to access a RESTful api. The base url is:
http://api.example.com/service
This is the code for the interface:
public interface ExampleService {
@Headers("Accept: Application/JSON")
@POST("/album/featured-albums")
Call<List<Album>> listFeaturedAlbums();
}
and this is how I send request and receive the responce:
new AsyncTask<Void, Void, Response<List<Album>>>() {
@Override
protected Response<List<Album>> doInBackground(Void... params) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.example.com/service")
.addConverterFactory(GsonConverterFactory.create())
.build();
ExampleService service = retrofit.create(ExampleService.class);
try {
return service.listFeaturedAlbums().execute();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Response<List<Album>> listCall) {
Log.v("Example", listCall.raw().toString());
}
}.execute();
the log that I get is the weird thing:
V/Example﹕ Response{protocol=http/1.1, code=404, message=Not Found, url=http://api.example.com/album/featured-albums}
What's going on here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…