Hi there,
I am trying to retrieve company profile using simple GET request using a newly generated REST API key for a new application and I am getting a 401 response;
output I get:
{‘error’: ‘Invalid Authorization’, ‘type’: ‘ch:service’}
This is my code;
api_key='i_input_the_API_key_here'
response = requests.get(
"https://api.company-information.service.gov.uk/company/15602770",
auth=HTTPBasicAuth(api_key, '')
)
print(response.json())
I also tried the CURL based GET request using the API KEY still getting 401 response.
Any assistance is much appreciated.
Using curl to test is a good idea!
When you registered, did you choose the “live” application mode? The test / sandbox one may have issues.
Did you enter the IP address (es) you are sending requests from (eg. with curl) - and or the javascript domain if doing javascript requests from a client (eg. not from node on a server)?
(Ah - are you using Python there? If so presumably you’re using that in a server rather than a browser?)
If you’re connecting from some container-based system / something like AWS or Google cloud compute that may affect things - there are some posts on the forum about those i think. You should be able to find them with the search if needed.
If you’re using a locally hosted site / web server on a workstation have you used the workaround for that (search this forum)?