Authentication issue with API on Salesforce

I have installed the app on my Salesforce sandbox. I have followed all the steps to configure.

An Apex error occurred: comp_house.CompanyHouseAPI.customSettingException: {“error”:“Invalid Authorization”,“type”:“ch:service”}

How shall I debug this? I have saved the api key on Salesforce as instructed.

Thanks
Richa Sharma

I don’t use Salesforce but looks like there are documents on working with that - e.g. here’s an example (only http, not https) using http Basic Authorization (in case your issue is “how to send that” - although perhaps you use a graphic interface to set this up):

Check the following in Companies House application registration:

  1. Ensure you chose “live”, not test/sandbox.
  2. Ensure you have either entered the server’s IP address(es) OR used the local host workaround (if using locally) OR registered the javascript domain name(s).

Double-check your API key as well, several people have gone a long way then found they weren’t using the key they thought they needed e.g. they’d an old key, or had the non-live key, or extra spaces…

Check you have the correct fields in the correct places. The system uses http Authorization - that means there is a username and a password. For some reason Companies House requires that you effectively have the “password” part (the API key) as the username, and the password is blank / empty.

There may be issues with setting that up in SalesForce:

It’s sometimes helpful to try another tool e.g. curl if you’ve got access to that (from your registered server) - it’s really simple and you can turn on a very verbose mode to inspect traffic. A simple test would be:

curl -u YOURAPIKEYHERE: https://api.company-information.service.gov.uk/company/03279730

Good luck.