# I am getting error "The remote server returned an error: (404) Not Found"

**URL:** <http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530>\
**Category:** Information\
**Created:** [March 29, 2016, 12:37pm UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530 "2016-03-29T12:37:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayesh\_baldha](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/j/bbce88/32.png) [@jayesh\_baldha](http://forum.companieshouse.gov.uk/u/jayesh_baldha)\
**Post date:** [March 29, 2016, 12:37pm UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/1 "2016-03-29T12:37:05Z")

</div>

I am wondering with company house api.

I am trying to call api with some company registration number.

company house api returning The remote server returned an error: (404) Not Found error if i am passing wrong company registration number.

If i am passing correct company registration number it gives me JASON response.

So how we can identified that company is not found or wrong company registration number from api response as give 404 error.

Please guide us.

Many thanks

---

<div class="post-metadata">

**Author:** ![mfairhurst](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/bbce88/32.png) [@mfairhurst](http://forum.companieshouse.gov.uk/u/mfairhurst)\
**Post date:** [March 29, 2016, 12:53pm UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/2 "2016-03-29T12:53:02Z")

</div>

@jayesh_baldha,

Could you provide the URL that you are requesting?

Thanks

@mfairhurst

---

<div class="post-metadata">

**Author:** ![jayesh\_baldha](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/j/bbce88/32.png) [@jayesh\_baldha](http://forum.companieshouse.gov.uk/u/jayesh_baldha)\
**Post date:** [March 29, 2016, 1:01pm UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/3 "2016-03-29T13:01:11Z")

</div>

‘[https://api.companieshouse.gov.uk/company/Orange156](https://api.companieshouse.gov.uk/company/Orange156)’ throwing 404 error

Whereas, ‘[https://api.companieshouse.gov.uk/company/05965465](https://api.companieshouse.gov.uk/company/05965465)’ is working fine.

thanks

---

<div class="post-metadata">

**Author:** ![rmcneil](http://forum.companieshouse.gov.uk/user_avatar/forum.companieshouse.gov.uk/rmcneil/32/225_2.png) [@rmcneil](http://forum.companieshouse.gov.uk/u/rmcneil)\
**Post date:** [March 29, 2016, 1:18pm UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/4 "2016-03-29T13:18:23Z")

</div>

URL construction requires company number ie [api.companieshouse.gov.uk/company/](http://api.companieshouse.gov.uk/company/) followed by the company number of the company you are interested in. ‘Orange156’ is not a company number and therefore returns a 404 not found because it cannot find it…

---

<div class="post-metadata">

**Author:** ![oxieking83](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/o/b5e925/32.png) [@oxieking83](http://forum.companieshouse.gov.uk/u/oxieking83)\
**Post date:** [September 18, 2016, 4:29pm UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/5 "2016-09-18T16:29:09Z")

</div>

Hello,  
Sorry to post in this topic but I was not sure if it was worth starting a new topic

I can call API from localhost, it returns JSON response. However, when I run it from my live website the IP and domains of which are in the API key settings, it returns 404 response.

Any idea why this could be?

Thanks.

---

<div class="post-metadata">

**Author:** ![mfairhurst](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/bbce88/32.png) [@mfairhurst](http://forum.companieshouse.gov.uk/u/mfairhurst)\
**Post date:** [September 19, 2016, 8:01am UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/6 "2016-09-19T08:01:55Z")

</div>

@oxieking83,

Is this for every call made? Can you provide details of which endpoint and any parameters provided?

Thanks

@mfairhurst

---

<div class="post-metadata">

**Author:** ![oxieking83](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/o/b5e925/32.png) [@oxieking83](http://forum.companieshouse.gov.uk/u/oxieking83)\
**Post date:** [September 24, 2016, 10:05am UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/7 "2016-09-24T10:05:28Z")

</div>

It is : **[https://api.companieshouse.gov.uk/company/](https://api.companieshouse.gov.uk/company/)" + companyID**

string credentials = String.Format("{0}:{1}", “MyAPIKey:”,"");  
byte[] bytes = Encoding.ASCII.GetBytes(credentials);  
string base64 = Convert.ToBase64String(bytes);  
string authorization = String.Concat("Basic ", base64);  
HttpWebRequest webReq = )HttpWebRequest)WebRequest.Create(“[https://api.companieshouse.gov.uk/company/](https://api.companieshouse.gov.uk/company/)” + companyID);  
webReq.UseDefaultCredentials = true;  
webReq.Headers.Add(“Authorization”, authorization);  
webReq.Method = “GET”;  
webReq.ContentType = “application/json”;  
HttpWebResponse webResp = (HttpWebResponse)webReq.GetResponse();

Sorry, actually now it gives 401 Error (when run live)  
Thanks.

---

<div class="post-metadata">

**Author:** ![mfairhurst](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/bbce88/32.png) [@mfairhurst](http://forum.companieshouse.gov.uk/u/mfairhurst)\
**Post date:** [September 26, 2016, 8:19pm UTC](http://forum.companieshouse.gov.uk/t/i-am-getting-error-the-remote-server-returned-an-error-404-not-found/530/8 "2016-09-26T20:19:03Z")

</div>

@oxieking83

If I’m reading the code correctly then you do not need to append the : at the end of your “MyAPIKey” in the following line of code

```
string credentials = String.Format("{0}:{1}", "MyAPIKey:","");

```

This colon is added through “{0}:{1}” with the api key replacing {0} and blank replacing {1} but with the colon in between.

Apologies if this is just a mistake in the posting of the code on the forum, please let me know.

Thanks

@mfairhurst
