401 Invalid Authorization

I tried using:
curl -u my_API_Key: "https://api.companieshouse.gov.uk/company/00048839"
to little success (getting “Invalid Authorization” error code), I had been using python and the request library but decided to try the command line as was facing the same error there. I can now see that it is not an issue with my python code and there instead must be an issue with either my application setup or some other factor that I am failing to see… does the “my_API_Key” have to be encoded somehow, base64 etc.?

If you’re using curl no, you have it right. Your issue is probably one of the fields you asked about in your other question. I’ve posted there - hope that helps.

1 Like

I observed the same issue in Postman, trying to pass the ‘Authorization’ header with value 'Basic ’

Where is the Base64 encoded value for ‘my_api_key:’ (key value followed by colon), am I missing anything?

The response body I get is:
“error”: “Invalid Authorization”,
“type”: “ch:service”

Search the forum. First check you understand the live vs. sandbox environments when creating your application. (I posted something about this recently but can’t find it immediately. Over to you!)

Second - ensure you understand http basic authentication or how to make this work in Postman. Postman use has been covered on this forum, search around.

If you’re still having issues try this in the simplest tool you can e.g. curl would be good! LOTS of examples of how to debug this on the forum and Companies House use that in their documentation / examples too…

Good luck.

Thanks! I checked other posts in this forum and managed to fix this thanks to your other comments! There were 2 issues: I was using a test app (instead of a live app), and I had to do the ‘localhost’ trick to allow requests to be executed from my laptop.

Thanks again!


Yes, Thanks a lot. Two steps need to take care of.

  1. Use Live app(instead of test app)
  2. Use Basic Auth in postman and use your API Key as username (left password field as empty)