I am trying to access the advanced search from front end Javascript fetch(). This call works for all endpoints I have tried apart from the advanced search endpoint. Here is the code.
var url = 'https://api.company-information.service.gov.uk/advanced-search/companies?company_name_includes=vodaphone';
var headers = new Headers({
Authorization: "Basic " + btoa(API_KEY + ':'),
"Content-Type": "text/json",
});
var obj = {
mode: "cors",
method: "GET",
cache: "no-cache",
headers: headers,
};
fetch(url, obj)
.then((resp) => resp.json())
.then((data) => console.log(data))
.catch(function(err) {
console.log(err);
});
This code works for most endpoints for example ‘https://api.company-information.service.gov.uk/search’.
However when calling the ‘https://api.company-information.service.gov.uk/advanced-search/companies?company_name_includes=vodaphone’ endpoint I get a CORS error. However it isn’t a 401.
I have whitelisted my domain on my REST API key and there are no IP restrictions and as I say the authorization works for other endpoints so I’m not sure what I am missing here.
Does the advanced search have a different authorization method than the other endpoints. All endpoints work when performing the calls through Postman.
Many thanks