# 401 Unauthorized using curl -\> resolved with switch from "test" app to "live" app

**URL:** <http://forum.companieshouse.gov.uk/t/401-unauthorized-using-curl-resolved-with-switch-from-test-app-to-live-app/8495>\
**Category:** API Issues\
**Created:** [September 20, 2024, 12:19am UTC](http://forum.companieshouse.gov.uk/t/401-unauthorized-using-curl-resolved-with-switch-from-test-app-to-live-app/8495 "2024-09-20T00:19:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbecker](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/3d9bf3/32.png) [@mbecker](http://forum.companieshouse.gov.uk/u/mbecker)\
**Post date:** [September 20, 2024, 12:19am UTC](http://forum.companieshouse.gov.uk/t/401-unauthorized-using-curl-resolved-with-switch-from-test-app-to-live-app/8495/1 "2024-09-20T00:19:38Z")

</div>

Colleagues, I’ve read multiple topics here regarding 401, but found no solution.

1. API KEY  
Entered after “-u” with “:” at the end, empty password
2. IP address (externally visible) - entered in Restricted IP list
3. Just to be sure - added domain gsl.dev for 127.0.0.1 to local hosts file and registered within my app as [http://gsl.dev](http://gsl.dev)  
Nothing helps - getting 401  
Any info/suggestion is welcome! Thank you  
 ![image](http://discourselive.s3.dualstack.eu-west-1.amazonaws.com/original/2X/9/9d754d3cef51885c4193bd978a976a888b69a054.png)

---

<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:** [September 20, 2024, 3:19pm UTC](http://forum.companieshouse.gov.uk/t/401-unauthorized-using-curl-resolved-with-switch-from-test-app-to-live-app/8495/2 "2024-09-20T15:19:18Z")

</div>

Is your application registered as a live one not test? (Yes… test should work but people have reported various issues).

Some people have also had issues with registering more than one API key and then using the wrong one, worth a double-check.

This exact endpoint (almost) works for us - although one note: it looks like you’re requesting:

[https://api.company-information.service.gov.uk/advanced-Search/companies](https://api.company-information.service.gov.uk/advanced-Search/companies)

With a capital “S” there - that will give a 404 error once you’ve sorted out the authorization issue. It should be:

[https://api.company-information.service.gov.uk/advanced-search/companies](https://api.company-information.service.gov.uk/advanced-search/companies)

(Obviously also calling a search endpoint without providing some parameters is in general odd!)

Good luck.

---

<div class="post-metadata">

**Author:** ![mbecker](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/3d9bf3/32.png) [@mbecker](http://forum.companieshouse.gov.uk/u/mbecker)\
**Post date:** [September 20, 2024, 8:36pm UTC](http://forum.companieshouse.gov.uk/t/401-unauthorized-using-curl-resolved-with-switch-from-test-app-to-live-app/8495/3 "2024-09-20T20:36:01Z")

</div>

Thx, @voracityemail  
Is your application registered as a live one not test? (Yes… test should work but people have reported various issues).  
mb: test. After I registered another “live” application - it worked with the “live” key immediately

Some people have also had issues with registering more than one API key and then using the wrong one, worth a double-check.  
mb: sure, maybe a problem. I’ve registered 2 keys and checked each one separately multiple times - none of the test “keys” did work

This exact endpoint (almost) works for us - although one note: it looks like you’re requesting:

[https://api.company-information.service.gov.uk/advanced-Search/companies](https://api.company-information.service.gov.uk/advanced-Search/companies)

With a capital “S” there - that will give a 404 error once you’ve sorted out the authorization issue. It should be:

[https://api.company-information.service.gov.uk/advanced-search/companies](https://api.company-information.service.gov.uk/advanced-search/companies)

mb: it worked with capital “S”, same way as with “s”, but only with the “live” key

(Obviously also calling a search endpoint without providing some parameters is in general odd!)

mb: yes, but it responded with a reasonable result.

Thx for the hint: the “live” vs “test” was the silver bullet

---

<div class="post-metadata">

**Author:** ![t.smallwood](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/t/839c29/32.png) [@t.smallwood](http://forum.companieshouse.gov.uk/u/t.smallwood)\
**Post date:** [October 9, 2024, 10:07pm UTC](http://forum.companieshouse.gov.uk/t/401-unauthorized-using-curl-resolved-with-switch-from-test-app-to-live-app/8495/4 "2024-10-09T22:07:20Z")

</div>

+1 and liked your answer. Live works, test didn’t.
