Retrieve officer id appointments - 502 Bad Gateway

I am having trouble with a particular part of the API.

I want to retrieve the appointments for a certain officer id.
I’m trying to do this by using UkCompaniesHouse::Officer.appointments(officer_id) in my rails app.

I receive this response:
502 Bad Gateway The server returned an invalid or incomplete response.

The steps I took were:

  • API Response Handling: Ensured that the API request was successful by checking the status code (200 OK). Thanks to @voracityemail 's reply. It returns 200.
  • Authorization: I confirmed that my API key is correctly set and has permissions for the request.
  • Correct Officer ID: I made sure the officer_id is valid and associated with appointments.
  • Parsing the Response: I double-checked that I’m using the correct path. But maybe the way it works has changed or been depreciated?
  • Rate Limits: Checked if I have hit any API rate limits, which might cause server issues. But I am good!

Ran into this issue yesterday and thought I’d come back to it today but still returning 502.

Any thoughts @companies.house.api ? Thank you!

I’ve not seen this today (have not checked logs yet though).

It is possible they’ve had some glitches - this has happened in the past - but every time I’ve checked I’ve got a valid response.

If the URL was incorrect I’d expect a 4xx code (400, 404) or (for a few edge cases) a 500.
Authorisation a 401 or (if you did something really odd) maybe a 500.
Rate limits you get 429 or a 409 response.

I guess it’s possible it’s something in your network environment causing issues also?

With all these I think if you hope for help from Companies House and it’s not a major thing affecting everyone - be as specific as you can.

If at all possible note the exact URL(s) you’re calling and the underlying network communications (probably more important here than details about what you’re doing higher level e.g. the language / libraries / framework you’re using - although ideally detail both!).

I think it’s helpful if you can translate this into a request you can make using the command-line curl tool. Companies House probably don’t use Rails (and not your app…) With that you can see detail on exactly what your system is sending and exactly what it’s receiving (ideally with time points for something like this).

Just remember to censor your API key e.g. in the http headers.

Ah thank you for this! I ran the curl request which returned a 200. So it turns out it was the gem wrapper for Ruby we were using that broke the request.

Thanks again.