# Connect via Postman says invalid authorisation header

**URL:** <http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149>\
**Category:** API Issues\
**Created:** [July 2, 2020, 3:00pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149 "2020-07-02T15:00:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![eoin](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/eoin/32/943_2.png) [@eoin](http://forum.companieshouse.gov.uk/u/eoin)\
**Post date:** [July 2, 2020, 3:00pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/1 "2020-07-02T15:00:08Z")

</div>

Hi there, I’m trying to connect via Postman.

I have set the authorisation to “basic” and I have added my key. It’s asking for a username too, but I don’t seem to have one. Does anyone know what I should put in here? I have tried putting the key in both and also putting “API Key” in the user name. I can see the header is basic and I believe Postman automatically base64 encodes the header.

```
{ "error": "Invalid Authorization header", "type": "ch:service"}

```

Can anyone help me?

---

<div class="post-metadata">

**Author:** ![voracityemail](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/v/b77776/32.png) [@voracityemail](http://forum.companieshouse.gov.uk/u/voracityemail)\
**Post date:** [July 5, 2020, 12:02pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/2 "2020-07-05T12:02:44Z")

</div>

I think this thread has you covered:  
[https://forum.aws.chdev.org/t/newbie-and-i-need-your-help-please/2785](https://forum.aws.chdev.org/t/newbie-and-i-need-your-help-please/2785)

The way CH do this: the http “username” is their “API key” and there is no password. I think that should be fine with Postman but there are some tools which seem to prevent “blanks”.

If you want to download the actual filing documents there are a couple of details to that. I’ve an answer here which might help if you need that:

[https://forum.aws.chdev.org/t/how-to-download-a-document-from-companieshouse-api-through-postman/1809](https://forum.aws.chdev.org/t/how-to-download-a-document-from-companieshouse-api-through-postman/1809)

You can normally find what you want with some searching on this forum or [reading the documentation](https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/apikey_authorisation.html). For example on this topic you might also try these threads:

[https://forum.aws.chdev.org/t/how-to-use-the-api-key-in-postman-and-node-js-request-module/586](https://forum.aws.chdev.org/t/how-to-use-the-api-key-in-postman-and-node-js-request-module/586)

[https://forum.aws.chdev.org/t/getting-invalid-authorization/41/7](https://forum.aws.chdev.org/t/getting-invalid-authorization/41/7)

Authorisation seems to be the biggest source of confusion. I guess this data / the API just has such a wide appeal that the numbers using it are large and the demographic is wide.

---

<div class="post-metadata">

**Author:** ![eoin](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/eoin/32/943_2.png) [@eoin](http://forum.companieshouse.gov.uk/u/eoin)\
**Post date:** [July 5, 2020, 1:24pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/3 "2020-07-05T13:24:23Z")

</div>

Thank you. Knowing not to put a password was extra information.

OK I followed these rules:

I have used basic authorisation.

I have put a colon at the end.

Postman automatically base 64 encodes it.

My url is: [https://api.companieshouse.gov.uk/company/06623345/registered-office-address](https://api.companieshouse.gov.uk/company/06623345/registered-office-address)

My API key works on the website, so the API is correct.

Eventually I used [https://www.base64decode.org/](https://www.base64decode.org/) to decode the header having followed all of the articles. This lead me to find out that my key was being used twice not once. Then I was able to find out where my username/password were still both set in Postman.

I set the collection to contain the authorisation as `basic` and only my **key** in the **username followed by a colon.**

I made sure password was empty.

I set the variables so I could use the base\_url, hence I set the variable name `base_url` and `https://api.companieshouse.gov.uk`

Then I set it to get and `{{base_url}}/company/06623345/registered-office-address` which worked.

---

<div class="post-metadata">

**Author:** ![eoin](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/eoin/32/943_2.png) [@eoin](http://forum.companieshouse.gov.uk/u/eoin)\
**Post date:** [July 5, 2020, 2:57pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/4 "2020-07-05T14:57:24Z")

</div>

If anyone ever gets stuck in the future you can simply import this JSON file to Postman and all of the requests are set up already. All you need to do is right click on “collections” click on “edit” and then click on “authorisation” and “variables” and change them to your own. Don’t forget to add a colon after your key.

> **[uglyeoin/companies\_house\_api\_\_postman](https://github.com/uglyeoin/companies_house_api__postman)**
>
> JSON Import file for the companies house API. Test the companies house API with no knowledge other than something like your company number. You will need to replace all of the variables within th...

---

<div class="post-metadata">

**Author:** ![michael.thileepan](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@michael.thileepan](http://forum.companieshouse.gov.uk/u/michael.thileepan)\
**Post date:** [May 20, 2021, 7:37pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/5 "2021-05-20T19:37:08Z")

</div>

Thank you so much @eoin This worked.

---

<div class="post-metadata">

**Author:** ![7rajnesh7](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/7/8491ac/32.png) [@7rajnesh7](http://forum.companieshouse.gov.uk/u/7rajnesh7)\
**Post date:** [May 27, 2021, 3:32pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/6 "2021-05-27T15:32:39Z")

</div>

Can you please let us know what was the header and authorization details you put?  
Please try to put some example… tried what have been mentioned by you but it is not working for me.  
help appreciated.

---

<div class="post-metadata">

**Author:** ![eoin](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/eoin/32/943_2.png) [@eoin](http://forum.companieshouse.gov.uk/u/eoin)\
**Post date:** [May 27, 2021, 3:47pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/7 "2021-05-27T15:47:50Z")

</div>

No problems, glad it helped

---

<div class="post-metadata">

**Author:** ![eoin](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/eoin/32/943_2.png) [@eoin](http://forum.companieshouse.gov.uk/u/eoin)\
**Post date:** [May 27, 2021, 3:50pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/8 "2021-05-27T15:50:14Z")

</div>

your key followed by a colon. → :  
e.g.  
asdlfkjasdlfkjadsf:

no password.  
authorisation type basic

are you using postman?

There is hardly any header information. Basic KEY  
e.g. Basic adsoijasldkjfasldkfj

---

<div class="post-metadata">

**Author:** ![7rajnesh7](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/7/8491ac/32.png) [@7rajnesh7](http://forum.companieshouse.gov.uk/u/7rajnesh7)\
**Post date:** [May 27, 2021, 4:32pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/9 "2021-05-27T16:32:54Z")

</div>

Yes I am using POSTMAN.  
below are the details,

URL - [https://api.companieshouse.gov.uk/company/06623345/registered-office-address](https://api.companieshouse.gov.uk/company/06623345/registered-office-address)

Headers  
Authorization - Basic \<my\_KEY\>:

here i am putting key generated on site.

Now i am getting error as “504 Gateway Timeout”

---

<div class="post-metadata">

**Author:** ![eoin](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/eoin/32/943_2.png) [@eoin](http://forum.companieshouse.gov.uk/u/eoin)\
**Post date:** [May 27, 2021, 6:17pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/10 "2021-05-27T18:17:20Z")

</div>

How you downloaded the API I made on Github? It has all of the calls in it properly. All you need to do is to put your key in the main configuration. Just click on the 3 dots and then click edit.

Make sure authorisation is Basic and put your key in as you have shown above. I didn’t put this into the headers I just let the config do it. I think it base64 encodes it automatically. Perhaps that’s the difference.

---

<div class="post-metadata">

**Author:** ![7rajnesh7](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/7/8491ac/32.png) [@7rajnesh7](http://forum.companieshouse.gov.uk/u/7rajnesh7)\
**Post date:** [May 31, 2021, 7:56am UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/11 "2021-05-31T07:56:18Z")

</div>

can you pls provide detail steps?

---

<div class="post-metadata">

**Author:** ![mike3](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/e99b99/32.png) [@mike3](http://forum.companieshouse.gov.uk/u/mike3)\
**Post date:** [February 27, 2022, 5:08pm UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/12 "2022-02-27T17:08:19Z")

</div>

Eoin, may thanks for taking the time to do this. After spending many hours today trying to get the API working your script is now up and running in postman on my machine… very good of you!!!

---

<div class="post-metadata">

**Author:** ![siddhant.kaushal](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/s/3ab097/32.png) [@siddhant.kaushal](http://forum.companieshouse.gov.uk/u/siddhant.kaushal)\
**Post date:** [March 17, 2022, 10:52am UTC](http://forum.companieshouse.gov.uk/t/connect-via-postman-says-invalid-authorisation-header/3149/13 "2022-03-17T10:52:46Z")

</div>

Hello @eoin,

Thank you very much for the detailed steps.

I don’t know how many hours I have spent on this API to make it work but still no luck for me. I have followed your postman steps as well. Changed the API\_Key followed by ‘:’ . Tried different ways to provide api\_key as well including base64. However I am still unlucky.

My deadline for API integration is approaching and I am worrying to implement it in Python. I have a list of company names. All I want is their company number that is provided by this API in the response.

No matter what I try in python or postman… I still get the same error.

{

```
"error": "Invalid Authorization",

"type": "ch:service"

```

}

Could you please help in any manner…

Thanks in advance.
