Trying to get basic company information - API giving {"error":"Empty Authorization header","type":"ch:service"}

I am trying to pass in the URL{company_number}. According to the documentation it does not require specific header parameters or any authentication.

Instead I keep getting {“error”:“Empty Authorization header”,“type”:“ch:service”} whenever i pass in the URL and put a company number.

Any help would be appreciated, Thanks.

a quick search on the forum should help:-

I have searched through and none of them provide a solution to my problem

Please post what your are sending in your headers.
Please post at least a code snippet detailing how you are calling our API.
As the error suggests, the problem is with the value you’re sending.

    ` //url of api service
        String data =  "";
        try {
            HttpsURLConnection conn = null;
            URL url = new URL(data);
            conn = (HttpsURLConnection) url.openConnection();
            conn.setRequestProperty(HttpHeaders.AUTHORIZATION, mContext.getString(R.string.api_key_companies_house));
            conn.setReadTimeout(10000 /* milliseconds */ );
            conn.setConnectTimeout(15000 /* milliseconds */ );
            //Log.i("responseCode1", String.valueOf(conn.getResponseCode()));
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            Log.i("responseCode2", String.valueOf(conn.getResponseCode()));
            String line;
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));

            // Read Server Response
            while((line = reader.readLine()) != null) {
            return sb.toString();
        } catch (UnsupportedEncodingException e) {
        }catch(MalformedURLException e){
        }catch (ProtocolException e){
        } catch (IOException e){

        return data;

I get a 404 response code. This is written in Java for an Android device. The authorisation is working now, but I am not receiving any data back from the server.

Have you managed to get your system working with our API ?

Unfortunately no. This time I’m getting a “400 Bad Request” from the server. Is there any example of working code in Java, C# or Python that I can have a look at?

reading the following may help:-