Basic Authorization in the URL problem

Hi, I’m trying to construct a URL to download a pdf document and the information I’ve found say the following construct should work, but I keep getting a 401. Is anyone able to help, E.g.


Even with the space after the colon replaced with a %20 I still get a 401

many thanks

1 Like

I have also tried having an Authorization header and putting the value 'Basic ’ in there

Following on from this what is the difference between using the API and having a key or just using the following (different) URL to get the data without an API key?

Welcome. To summarise this post - if you just want to get a few documents (filings) then using the Companies House Find and Update company website to search is simplest. Alternatively you may wish to register for API access (e.g. programmatic access to data). If you wanted a large amount of data then the “Bulk Data products” are the way to go.

It looks like you’re trying to use a garbled version of using the credentials in the URL to pass a username and password for http authorization. This is generally not recommended e.g. see the “Access using credentials in the URL” section in the article on http Basic from Mozilla.

Firstly - if you wish to use the API you will need to register to use this. It is free but you do need to register to obtain an “API key” (note - confusingly this is the “username” part of the http Basic authorisation - in use the “password” part is blank).

If you didn’t already I recommend reading through Companies House documentation. I’d also recommend the information pages made by another forum user - For downloading filing documents I recommend reading some of the detailed posts on this forum as this sometimes causes people trouble. You can search for these using the search icon at the top right.

Your third post asks about the difference between using the API and using the URL for the Companies House website directly. I don’t know the exact differences but if you are planning to access things programmatically then using the API is the way to do it. There is no guarantee that the form of the URLs on the web site won’t be changed with no notice at all - or the format of the data received will stay the same. The API can of course change but there should be some notice on this forum! It is also possible that the web site may have different rate limiting or detect “unusual access” and block your IP address if the system thinks you are attempting to access other than expected.

Good luck (and read the documentation!)

1 Like

From my understanding this is the correct way of adding Basic Authorization to the URL. I appreciate it exposes the credentials but it is not going to be published, it will only be available to the person with the key, i.e. me

The issue I believe is due to the fact that the password is blank and I was seeing if anyone had found a way to pass the key/username in alone


Passing the username (API Key) and the password (blank) in this way “works” but as well as not recommending it I’m not sure it will work for getting documents.

I’d recommend a different tool whatever you’re doing. If you’re just doing this manually then use the Companies House website. Otherwise I don’t see why you’d want to use a browser to make your requests. Some tool like e.g. curl or something you can program / script - even javascript - would give you more control over the requests and assist with debugging.

You can check this yourself - again not recommended - e.g. requesting something like

…(or some other valid company number on the end) should get a 200 response and a JSON payload. If you can’t do this then there is something wrong with your API key / a quirk of your browser / you haven’t registered a live domain or IP.

The issue with the Documents API is that your browser / whatever is doing the http GET for you needs to manage one or more redirects to another domain and not try to pass your API key there. You probably also want to specify the format of the document which you’d normally do with the http Accept header. You can’t pass that using the URL as far as I’m aware.

For more information on the Documents API and its quirks see e.g.: