I have just run the following to show you the entire process on one filing. (If you want more info on the full process please read the information I linked to, or just search on the this forum using the “magnifying glass” icon at the top right).
I like to use curl (a simple command line tool) to manually test things. It’s simple, readily available and you can see exactly what is sent / returned. I think you should do this to check exactly what is happening and any errors / responses. If you see errors when doing the following this might be due to:
-
Using the wrong API settings (e.g. not using the live but using the “sandbox” environment, use of “localhost” without having used the fix to set an alias in your hosts file etc.). You can search this forum for more info on that.
-
Limitations / details you need to work around in your Microsoft automation tool. (I know nothing about that).
-
Network issues e.g. maybe you have a firewall blocking something
Those are up to you!
Starting from looking up the filing history for company SC327000 (I’ve limited this to 2 items to save space and I’ve snipped information from the response - marked “…”. I’ve also formatted the JSON return for clarity - it will be returned without the spacing / new lines obviously). You’ll need to enter your own API key.
curl -u YOUR_API_KEY: "https://api.companieshouse.gov.uk/company/SC327000/filing-history?start_item=0&items_per_page=2"
{
"items": [
{
"category": "officers",
"description": "appoint-person-director-company-with-name-date",
"date": "2021-11-03",
"transaction_id": "MzMxOTA3NDIxOGFkaXF6a2N4",
"links": {
"self": "/company/SC327000/filing-history/MzMxOTA3NDIxOGFkaXF6a2N4",
**"document_metadata": "https://frontend-doc-api.company-information.service.gov.uk/document/mixpA6C5NJo7r0SZ2ypIiLCLM4XtZMnHZKMcHestIKI"**
},
...
},
{
"category": "officers",
"description": "termination-director-company-with-name-termination-date",
"date": "2021-09-30",
"transaction_id": "MzMxNTYyODMzMWFkaXF6a2N4"
...
"links": {
"self": "/company/SC327000/filing-history/MzMxNTYyODMzMWFkaXF6a2N4",
"document_metadata": "https://frontend-doc-api.company-information.service.gov.uk/document/DF_f0_3zuroMElPj05Tv_nLWWNCKxk8dTe1Mo8nCn8k"
},
...
}
],
"filing_history_status": "filing-history-available",
"items_per_page": 2,
"start_index": 0,
"total_count": 252
}
Take whatever is in the document_metadata
- and just request that. Here’s the first one:
curl -u YOUR_API_KEY: "https://frontend-doc-api.company-information.service.gov.uk/document/mixpA6C5NJo7r0SZ2ypIiLCLM4XtZMnHZKMcHestIKI"
{
"company_number": "SC327000",
"barcode": "XAGI54RL",
"category": "officers",
"pages": 2,
"filename": "SC327000_ap01_2021-11-03",
"links": {
"self": "https://document-api.companieshouse.gov.uk/document/mixpA6C5NJo7r0SZ2ypIiLCLM4XtZMnHZKMcHestIKI",
"document": "https://document-api.companieshouse.gov.uk/document/mixpA6C5NJo7r0SZ2ypIiLCLM4XtZMnHZKMcHestIKI/content"
},
"resources": {
"application/pdf": {
"content_length": 90224
}
}
...
}
This tells you there is a PDF format version available, at what is in the document
member. Take that. If there is more than one entry in resources you can use the http header “Accept” to specify which you want e.g. Accept: application/pdf
. In curl this would be --header "Accept: application/pdf"
. I’ve also specified the -I flag to show the header information and the -X GET (otherwise we get a complaint because by default -I sends a HEAD command I think).
The first thing you’ll get back is a redirect (302). Currently this will send you to Amazon AWS. To show
curl -u YOUR_API_KEY: -I --header "Accept: application/pdf" -X GET "https://frontend-doc-api.company-information.service.gov.uk/document/mixpA6C5NJo7r0SZ2ypIiLCLM4XtZMnHZKMcHestIKI/content"
HTTP/1.1 302 Found
Date: Mon,
14 Feb 2022 09: 17: 57 GMT
Location: https: //s3.eu-west-2.amazonaws.com/document-api-images-live.ch.gov.uk/docs/mixpA6C5NJo7r0SZ2ypIiLCLM4XtZMnHZKMcHestIKI/application-pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAWRGBDBV3DJKBSBZ6%2F20220214%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220214T091757Z&X-Amz-Expires=60&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEDwaCWV1LXdlc3QtMiJGMEQCICpmdATAsFtTe1exlaV2By%2B3EsjkoG8luFO82QlVCTgJAiAi%2BibCOQUnYsm1hsIQzlkTVFLq8T716mVACh8ytDbTZCqDBAiF%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAQaDDQ0OTIyOTAzMjgyMiIMqJbz5WsgE86qCTKkKtcDP%2BQbPoVEPEDSUso%2B0EzNdIGjdAFxISrm9WIWqvHvQd1FZNeWFE9e7oxI%2BUPExhJstQuaWjZ6BnnVUuf97zkjSc8Le%2FzlKozp%2Ba3rVX3k5jx8B19NrW84GNBLppBirsOkttj3MY74VTlL5NBqOFY9mrX6yAgYaS3oY3c1BLbq5EcoOYdVVuGqd1YtJr5HIuz0OexsyTZRC2NGQ4zZI0SygZuFHNcv6YNsN7PKLlPKMub9xcyfrtsJi%2BsZJEkmUWmTDQ4er92wZGALincsg%2BJ5%2Bsl2Marfbu%2FSNQN%2F6XbY3qoxaRTLZr93bP1JGqOZ0sLPRkJdMzG6672FPU3nQvirNSj15pd7Znp1XvPH9pd0DWBFWJV32AQrqDNOhgL%2B1A44TyfZZRfkcWaOEITd4UhIODRIEIeUvZRK3NKGJoQj73KnKhCbb%2F7SmXkeJC32ikDxlejYDtPlCikA2HAYoK%2Bhsm%2BOkqfnFfkVXZajwNCmKqOlH%2FbfMWSQeYjovzYRclaYYooUZJjC5rkBgC8ACfdP%2Fhbewq%2B%2BJnRiROECJBWIUbupid7j5TRNJt2SIY6eRpaQOaXxnkMkychRthoaLgljY1h3Bf8tSUpVLEYvEfmnXQx14YN6SQaoMKWep5AGOqYBcyEgdy9XTWJCaPjKHaDDnNY2Z95dV2gJHzkNvbUe8nPoEM2DtBG%2BAOoiLuXbDKSUas3wsaJByeDyFKGjNUongcLUkoqAQZslSDzIZBapGYNL6fImE2XFCHLUBfRvjp2XzYccoBu%2FqB%2B3iwNmtL7hPYqzK%2FWMoFIvHWXAhdHzFZ5F9xw%2Fqtrb55n8dVUqpzwmNGXNZtY%2B0IYADhy%2FslUeRXor1W3VFQ%3D%3D&X-Amz-SignedHeaders=host&response-content-disposition=inline%3Bfilename%3D"SC327000_ap01_2021-11-03.pdf"&X-Amz-Signature=7075c5755209fdf7bfe05c191972a6f24fe8b377103ba980b1f41ed2a7adbc97
Server: nginx/1.18.0
X-Ratelimit-Limit: 600
X-Ratelimit-Remaining: 598
X-Ratelimit-Reset: 1644830362
Content-Length: 0
Connection: keep-alive
The link above is time-limited e.g. if you try to use this one it will fail - you’ll need to follow this process and get it yourself.
When you make the request to Amazon you should not send your companies house username and password (the API KEY part). a) It’s not appropriate since Amazon isn’t Companies House and b) this will likely cause Amazon to get confused and the communication to fail.
Amazon may also redirect you - I can’t remember. If you want curl to automatically follow all links use the -L flag.
curl -L "{your own version of the link above}" > test.pdf
That successfully downloaded the PDF for me.
Good luck.