Problems with accessing the Get Document service with Java

I am having trouble accessing the Get Document service using Java.

Even on using the Try it Out! option on the website it just sits there and does nothing.

I am accessing the Meta Data part of the service using Java without issue, so it isn’t a problem with authentication, and have accessed Get Document using cURL, getting a 302 response with a valid location included. Using verbose on cURL shows that my request parameters are the same (“GET /document/[ID]/content HTTP/1.1”, “Host: document-api.companieshouse.gov.uk”, “Accept: application/pdf”, “Authorization: [same between cURL and Java]”), the only differences are “User-Agent: curl/7.45.0” vs “User-Agent: Java/1.6.0_10” (although I have passed curl/7.45.0 in with Java to no avail) and passing “Connection: keep-alive” in using Java (I have set this to null, but it made no difference).

I am constantly getting 401 errors when I run using java, but using cURL for the same service and using Java for getting Document Meta Data are returning fine. Does anyone know what the problem could be?

@richard

This could be related to the HTTP client library automatically following the redirect in the metadata request and sending the the original authorisation header? The following post provides some further explanation.

Let me know if this helps.

Thanks,

Mark.