0

I can't manage to get the JSON content with a GET http request. I got the html/text content, even when I try to specify the "Accept" http header in my request.

URI uri = new org.apache.http.client.utils.URIBuilder(url) .setParameter("departureLat", "601718") .setParameter("departureLng", "2414450") .setParameter("arrivalLat", "600797") .setParameter("arrivalLng", "2429000") .build(); Request request = Request.Get(uri) .connectTimeout(5000) .addHeader("Accept: ", String.valueOf(ContentType.APPLICATION_JSON)) .socketTimeout(timeout); HttpResponse response = JsonTools.execute(service, uri, request, content); 

Any idea ? :)

1 Answer 1

2

Try:

 .addHeader("Accept", String.valueOf(ContentType.APPLICATION_JSON)) 

Most libraries expect the header name alone, without the colon or space.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.