Help with Document API & Fetch a Document

Paul,

Assuming you have identified the document you want from the filing history response, the steps are:

  1. Set your mandatory HTTP request headers.

    Accept: application/pdf
    Authorization: Basic your_encoded_key_goes_here

  2. Invoke https://document-api.companieshouse.gov.uk/document/{transaction_id}/content where transaction_id relates to the document of interest in filing history response. E.g.

    https://document-api.companieshouse.gov.uk/document/n1EjP_MALLs8xZp5hs86iHcYDli0TE-n6t4HUDeZuq8/content

  3. Retrieve the location header from the HTTP response. The headers you get back will include:

    Content-Type: text/plain; charset=utf-8
    Date: Fri, 04 Sep 2015 15:18:36 GMT
    Location: https://s3-eu-west-1.amazonaws.com/document-api-images-prod/docs/n1EjP_MALLs8xZp5hs86iHcYDli0TE-n6t4HUDeZuq8/application-pdf?AWSAccessKeyId=blahblahblahblah_plus_other_attributes
    Server: nginx/1.6.2
    X-Ratelimit-Limit: 600
    X-Ratelimit-Remaining: 599
    X-Ratelimit-Reset: 1441380216
    Content-Length: 0
    Connection: keep-alive

    Note the response body is empty if all goes well!

  4. Connect to the https location and download your document.

I’ve avoided technical details but have successfully implemented this in Java.

I hope this helps.

Andrew

1 Like