Reputation: 11
The API response I'm requesting contains multiple pages. In the header of the response is the current page and the last page sent in a format I don't know how to handle. All the other headers are Strings. If I for example request the following header:
Request request = new Request.Builder().url(url).head().build();
Response response = client.newCall(request).execute();
return response.header("date").toString();
I get this result:
Wed, 06 Jun 2018 10:00:31 GMT
The wanted result is under the header "link" and is showed in Postman as follows:
Link →https://api.schiphol.nl:443/public-flights/airlines?sort=%20publicname&app_id=***&app_key=***&page=7; rel="last", https://api.schiphol.nl:443/public-flights/airlines?sort=%20publicname&app_id=***&app_key=***&page=1; rel="next"
When I try to return the header "link" I get a null pointer. How do I do this?
Thanks in advance!
Upvotes: 0
Views: 3166
Reputation: 743
You can try to use: response.getHeaders().get("link")
to get the value.
Upvotes: 1