API randomly returning 401s & 503s

Thank you for the update @MArkWilliams . Appreciate that these outages can and will happen time to time and thatCH team have worked hard to resolve the issues.
Regular updates like these help us to manage expectations downstream.

@MArkWilliams thank you for your transparency and hard work. Can you confirm that all issues are resolved please? We are still experiencing challenges with the officers resource. Company is fine.

One thing I have noticed about the company officers endpoint (as it’s causing us issues). Requests like

https://api.companieshouse.gov.uk/company/15250905/officers?items_per_page=10&start_index=0&order_by

worked fine up until last weekend, now it seems we need to either get rid of the order_by or add a value like “surname” to it.

We’re still getting 401 errors on all officer queries. Companies and PSCs look fine though.

Thanks

This is under investigation. There has been a change, it was actually to fix a problem with ordering.
I have asked for some advice from the developers, which I will post on this post Company Officers LIST Ordering of results changes

posting here for completeness…

OK, so the order was one of the fixes, so it has technically changed but only so it is now working correctly.
The default order is now active. So if you just want all active officers, then just leave the order_by off and it will use the default which shows active officers first anyway.

Alternatively for active directors then add filter=active to the query e.g. https://api.company-information.service.gov.uk/company/00006400/officers?filter=active&items_per_page=25

or similar.
Hope that helps

Hi @MArkWilliams ,
I am getting 401 status code while fetching requests via python,

I am currently using the below method to handle the requests which was previously working fine but giving 401 error from the last couple of requests:

url = f'https://api.company-information.service.gov.uk/company/{company_number}/registered-office-address'
    headers = {
         'Authorisation': f'Basic {encoded_key}'         
    }
    api_request = requests.get(url, headers=headers)

I think that the Header is the issue here - try Authorization as the spelling in the header.

Hope it helps.

Yes, it is Authorization in the actual code, Grammarly autocorrected this to British English while posting here.

Hello @sarvesh.nahar - Okay, so do you agree that a 401 error is a Header Auth issue?

I ran your code in Python and it would not parse for me - I did get this version to parse;

url = f’https://api.company-information.service.gov.uk/company/SC574952/registered-office-address
api_request = requests.get(url, Headers=‘Authorization’ f’Basic {encoded_key}’)

The main difference I can see is that removing ’ : ’ from the code in the Header section.

I also tested this in Postman and got this;


I think proving the call is correct - just an issue with your header formatting?

Hope it helps.

Yes, it did solved the issue initially, but now I am getting error 500, any idea how to handle this?

If you’re still having issues with the server returning a 500 type error, after waiting a while to allow CHS to clear any issues on their side, then can you post an image of the screen, first removing any sensitive keys or code.

This will allow for a better understanding of the issue you are seeing - thanks :upside_down_face: