Wanted simple instructions to use API in streaming or REST

I asked the following question, but I seem to have got it working by posting and adapting the example curl request into postman as a raw text import. I have not tried to do it with a test application. The guidance for the import into postman was on httprequest - Simulate a specific CURL in PostMan - Stack Overflow.

I have looked at related questions in the forum and tried all of the proposed solutions (including creating a live rather than test app).
Each time, I either receive no data (using sandbox) or get an authorization error. Is it possible for someone to set out in relatively simple terms the steps to send a REST request? I am sorry to say, I have not found the developer pages helpful. I have tried using postman or sending from extensions in Visual Studio code, but none work. I would prefer to use the REST.
The error I get is
{

“error”: “Invalid Authorization header”,

“type”: “ch:service”

}

Welcome. It is not clear what you are trying to do here. It sounds like:

  1. You have a valid API key / application (“I seem to have got it working by posting and adapting the example curl request into postman as a raw text import”)
  2. … but then you say “I have tried using postman or sending from extensions in Visual Studio code, but none work.”

Did you ever successfully manage to get a response with data from the Companies House server or not?

When you say “Is it possible for someone to set out in relatively simple terms the steps to send a REST request?” - REST just means this style of communication. So - if you’re accessing e.g. the Companies House Public Data API you are using a REST-style API however you make the requests, whether from curl, Postman, Visual studio code extensions etc.

As always I recommend starting with curl itself. This is because it’s installed on or available for most systems, it is very simple and doesn’t hide things from you and indeed you can turn on verbose mode to see extra information. That will at least allow you to ensure that:

a) You actually have a valid API key.
b) You’ve correctly understood that the API key actually goes in the “username” position when performing http basic authorization (a design choice by Companies House which apparently catches lots of people out).
c) You can see what data / http response code you get back.

You say you have looked at related questions on this forum. I’m pretty sure people have managed to use things like Postman successfully so it may just be a matter of working through all those posts again to find the bit you’re missing.

As for “simple instructions” - I’m sure all the necessary information is out there somewhere, not necessarily in a single document. I wonder if ChatGPT might even be able to help these days (I have not tried it personally but lots of people seem to be using it for technical queries)? :slight_smile:

If after all that you are totally stuck then for others on this forum to be able to help you it might be useful to provide some extra information:

  • What endpoint in which API you are trying to access? Example: "I am trying to get the Company Profile resource via the Companies House public data API using the Company Profile endpoint.

  • As much detail as you can about what you’re actually sending to Companies House. If you’re having authorization issues then the key is what exactly you’re sending in the “Authorization” http header. Don’t post your actual API key though. You could even manually encode a “dummy” username and password (or in Companies House terms your API key plus the “:” character) to show the process you’re following.

  • an example of a URL you’re requesting e.g.
    “I make a GET request to https://api.company-information.service.gov.uk/company/00445790”

  • both the http response code (e.g. 400, 401 etc.) AND any http body you receive e.g. like the JSON error you posted.

Good luck.

Thank you, I did manage to sort this out by using the information on the Stack overflow site.

1 Like