Reputation: 7914
@GET("/city/{cityId}/category/all")
Observable<MyDictionary> getDictionaries(@Path(value = "cityId", encoded = true) String cityId, @HeaderMap Map<String, String> headers);
Call method to retrieve data:
service.getDictionaries(cityId, headersMap)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(resp ->
{
/*...............*/
}, throwable ->
{
/*...............*/
});
I can get reposne eaisly. But I also need to know response headers. How to access them in my code? Any tips? I'm getting only body, how to get headers also?
Upvotes: 3
Views: 1160
Reputation: 4269
You can get response headers
this way:
Set response type as Observable<Response<MyDictionary>>
as following:
In Service Interface:
@GET("/city/{cityId}/category/all")
Observable<Response<MyDictionary>> getDictionaries(@Path(value = "cityId", encoded = true) String cityId, @HeaderMap Map<String, String> headers);
and while calling api: you would be able to get headers by :
response.getHeaders()
method.
Upvotes: 5