Authorisation problems API

I’ve been reading through the forum and can’t find a resolution for the authorisation issue I keep getting.

I keep getting the error:
{“error”:“Empty Authorization header”,“type”:“ch:service”}

As an example, I am making a GET request and using the URL: https://api.companieshouse.gov.uk/search/companies?q=explore+all+options

I have tried to change my header name & value to a range of different options:

  • Authorisation:
  • ETag
  • ch:service
  • Credentials

Etc. but nothing is working. Do you know how I can resolve this? I’m using an online tool called Integromat which would be incredible if I can get this to work

Image of the setup on Integromat

I know nothing about Integromat but:

  1. Your image shows using the ETag header. To get in, you definitely need the “Authorization” header (with every request [ minor detail - see $$$]), and the value should be the base64 encoding of your API key + “:” (for why, see e.g. the Wikipedia http Basic article).

This is assuming that Integromat don’t already recognise Authorization headers as special. If and only if they do you’ll likely be prompted for a username - which is your API key - and password - which will be an empty string. Then their component should assemble this and base64 encode it (as in the step above) when it’s actually sent.

So it’s all as in the Companies House documentation . There they show how to input that into curl and also the actual header fields as sent (which is how you’ll need to enter them it seems). Search the forum / check the Wikipedia http Basic article if stuck.

  1. However once you get that bit working the process may still not work at all. Companies House requires you to register your IP / host name (when you “add an application” when signing up) and I believe that this information is then checked when your request comes in. Whether you can make this work depends on how Integromat works and what you can register with Companies House. Presumably the Integromat requests originate from one of their servers? If so presumably you’d have to find a way of specifying their IP addresses and I’m not sure CH lets you register a range. If the request comes from a browser / client / javascript then presumably you’d need to register the domain name - but that likely wouldn’t be your domain name but a one belonging to Integromat (which other people also could use etc.)?

I can’t help further on point 2) but if you run into trouble you might be able to find something by searching the forum for how / if other platforms integrate with CH - e.g. like “azure”, “lambda”, “aws” etc. Seems one issue is that “multiple client” sites tend to get blocked e.g. see:

$$$ one detail here is if you’re using the document api - when you actually download the content of the document there’s a redirect step on to (as of 2020-07) Amazon AWS server and at that point you should not be sending on the Companies House auth header because a) it’s a different host / domain and b) Amazon have their own authorisation and if you send the CH one as well they’ll reject the request.

Good luck.