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

**URL:** <http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676>\
**Category:** API Issues\
**Created:** [October 23, 2019, 7:27pm UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676 "2019-10-23T19:27:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![a\_phil](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/a/ecb155/32.png) [@a\_phil](http://forum.companieshouse.gov.uk/u/a_phil)\
**Post date:** [October 23, 2019, 7:27pm UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/1 "2019-10-23T19:27:13Z")

</div>

I am trying to pass in the URL [https://api.companieshouse.gov.uk/company/{company\_number}](https://api.companieshouse.gov.uk/company/%7Bcompany_number%7D). According to the documentation [https://developer.companieshouse.gov.uk/api/docs/company/company\_number/readCompanyProfile.html#here](https://developer.companieshouse.gov.uk/api/docs/company/company_number/readCompanyProfile.html#here) 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.

---

<div class="post-metadata">

**Author:** ![MArkWilliams](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/markwilliams/32/194_2.png) [@MArkWilliams](http://forum.companieshouse.gov.uk/u/MArkWilliams)\
**Post date:** [October 23, 2019, 10:01pm UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/2 "2019-10-23T22:01:26Z")

</div>

a quick search on the forum should help:-  
[https://forum.aws.chdev.org/search?q=Empty%20Authorization%20header](https://forum.aws.chdev.org/search?q=Empty%20Authorization%20header)

---

<div class="post-metadata">

**Author:** ![a\_phil](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/a/ecb155/32.png) [@a\_phil](http://forum.companieshouse.gov.uk/u/a_phil)\
**Post date:** [October 23, 2019, 11:06pm UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/3 "2019-10-23T23:06:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MArkWilliams](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/markwilliams/32/194_2.png) [@MArkWilliams](http://forum.companieshouse.gov.uk/u/MArkWilliams)\
**Post date:** [October 24, 2019, 10:51am UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/4 "2019-10-24T10:51:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![a\_phil](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/a/ecb155/32.png) [@a\_phil](http://forum.companieshouse.gov.uk/u/a_phil)\
**Post date:** [October 27, 2019, 4:13pm UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/5 "2019-10-27T16:13:28Z")

</div>

```
    ` //url of api service
        String data = "https://api.companieshouse.gov.uk/search/companies?q=Apple";
        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 */ );
            conn.setDoOutput(true);
            conn.setRequestMethod("GET");
            //Log.i("responseCode1", String.valueOf(conn.getResponseCode()));
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            Log.i("responseCode2", String.valueOf(conn.getResponseCode()));
            wr.flush();
            wr.close();
            String line;
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));

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

        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.

---

<div class="post-metadata">

**Author:** ![MArkWilliams](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/markwilliams/32/194_2.png) [@MArkWilliams](http://forum.companieshouse.gov.uk/u/MArkWilliams)\
**Post date:** [November 7, 2019, 10:59am UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/6 "2019-11-07T10:59:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![a\_phil](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/a/ecb155/32.png) [@a\_phil](http://forum.companieshouse.gov.uk/u/a_phil)\
**Post date:** [November 7, 2019, 3:06pm UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/7 "2019-11-07T15:06:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![MArkWilliams](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/markwilliams/32/194_2.png) [@MArkWilliams](http://forum.companieshouse.gov.uk/u/MArkWilliams)\
**Post date:** [November 7, 2019, 3:52pm UTC](http://forum.companieshouse.gov.uk/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676/8 "2019-11-07T15:52:05Z")

</div>

reading the following may help:-  
[https://forum.aws.chdev.org/t/how-to-use-api-with-python-can-anyone-help-me-on-this-thanks/2501](https://forum.aws.chdev.org/t/how-to-use-api-with-python-can-anyone-help-me-on-this-thanks/2501)  
[https://forum.aws.chdev.org/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676](https://forum.aws.chdev.org/t/trying-to-get-basic-company-information-api-giving-error-empty-authorization-header-type-ch-service/2676)  
[https://forum.aws.chdev.org/t/c-example-to-authorise-and-get-data-from-api/388](https://forum.aws.chdev.org/t/c-example-to-authorise-and-get-data-from-api/388)  
[https://forum.aws.chdev.org/t/authentication-issue/322](https://forum.aws.chdev.org/t/authentication-issue/322)
