Company Officers 404

I am trying to access the office list of a few different companies using python. I have a 200 response for a few of them but not for the great majority of them.

E.g.

url = 'https://api.company-information.service.gov.uk/company/08132192/officers
response = requests.get(url,auth=(api_key,''))

This works fine (response status = 200)

This one doesn’t (response status = 404):

url = 'https://api.company-information.service.gov.uk/company/1095437/officers'
response = requests.get(url,auth=(api_key,''))

Any idea why?

I suspect it’s because the company registration number for the second company is only 7 digits long. A valid company registration number needs to be 8 digits long. Try adding a leading zero to the number you provided i.e. 01095437 and see if that fixes the issue… I am able to get officer details for that company because I have the folowing line in my code:
if (searchInput.All(char.IsDigit))
{
string companyNumber = searchInput.PadLeft(8, ‘0’);
}

1 Like

Fabulous! It’s working. Thanks @SmokeAndMirrors! :slight_smile: