Hello. we have a problem with using Company Search API. (https://developer.companieshouse.gov.uk/api/docs/search/companies/companysearch.html#here) We pass authorization, but we have empty result. Also we have compared request from test form and our and it’s totally same. What is the problem?
Screenshot of form request:
Screenshot of us request:
We get 200 code answer but result is empty.
@gchacko
Could you confirm. When you say from “test form” is that the “Try it out” functionality on the developer site? And to be clear does that work?
Thanks,
@mfairhurst
Hi
- We do not have issues with the “Try it out” functionality on the developer site, this is working
- We do have issues when we try to integrate the API into our web application.
We are doing the following:
$http.get(‘https://api.companieshouse.gov.uk/search/companies?q=’ + company, { headers: { ‘Authorization’: api.company, ‘ACCESS-TOKEN’: undefined } })
api.company - Basic API-KEY (we are using our token)
Our results are as below:
- We get return message 200 but the result is empty (please see screenshot link below)
Screenshot of form request:
Screenshot of our request:
Could you please help us understand what we have to do to resolve this.
Thanks
@george_chacko
Could you possibly send us a runnable test version of the code so we can investigate further, as we cannot see any issues with the information provided so far.
Thanks,
@mfairhurst
Please find the link below to the application
http://test.bookamed.com/ - please enter “bookamed” and then in debug you can see the results (200 and empty results)
We would also like to understand if there is any FILTER that you are applying on our URL http://test.bookamed.com (we have registered the application and provided the URL to get the API key)
@george_chacko
The issue is CORS related. If you look at the console window in Chrome when using the site the following error message is returned
You need to add your domain (http://test.bookamed.com) to the list of “Authorised JavaScript domains”, in the developer hub, which can be defined against the API key you are using. This can be achieved as follows: -
- Sign into the devleloper hub
- Select your applications
- Click on the application in question
- Click edit details
- Enter the domain (http://test.bookamed.com) in the Authorised JavaScript domains box
Hope this helps,
Thanks
@mfairhurst
the domain is already added into the “Authorised JavaScript domains”. we have tested the API after doing so.