Connecting to companies house api using RestSharp/ C#

Hey guys

I am trying to access companies house api using RestSharp (C#).
Can someone let me know how and where should I be adding the api key?

Many thanks

@santhosh_rajappan

The Companies House API uses HTTP Basic Authentication to transmit an API key between the client application and the server. Basic authentication is usually made up of a username and password pair; the Companies House API takes the username as the API key and ignores the password, so can be left blank. This is documented on the [developer hub][1].

Iā€™m no expert in RestSharp (C#) but some quick reading indicates that a GET using the client will not encode the username and password so you will have to replace the username, password with the base 64 encoded version of your_api_key plus a colon, as a separator between the username and password is required (NB you will need to append the colon to the end of the api key before encoding)

Hope this helps

Thanks

@mfairhurst
[1]: https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/apikey_authorisation.html

1 Like

@mfairhurst Many thanks for the response. This is helpful.