2

I have a url with ending &filename=xxxx after hitting it through browser, it redirects to some XXX url start downloading the expected zip file.

When I try to hit the same url through Java code, it reutrns 406 Not Acceptable. After search in internet, I have tried following attempts

HttpUriRequest request = new HttpGet(URL).addHeader(HttpHeaders.CONTENT_TYPE, "application/zip"); request.addHeader("Accept", String.valueOf(ContentType.APPLICATION_OCTET_STREAM))

When I tried to change in the execute method itself, httpClient.execute(new HttpGet(httpUrl), httpClientContext) HttpGet object not converted to HttpUriRequest and returns Hostname as null error.

aarav
  • 230
  • 1
  • 4
  • 21

0 Answers0