I’m using the code as given to look up company data, but I’m getting an error if I use it anywhere except on this page to test the endpoint.
What am I doing wrong?
This is the result I get:
{"message":"Bad Request: There was an error parsing the input","status_code":400}
const url = 'https://linkedin-company-data.p.rapidapi.com/linkedInCompanyDataJson';
const options = {
method: 'POST',
headers: {
'content-type': 'application/json',
'X-RapidAPI-Key': 'API_KEY',
'X-RapidAPI-Host': 'linkedin-company-data.p.rapidapi.com'
},
body: {
liUrls: [
'https://www.linkedin.com/company/hilton/'
]
}
};
try {
const response = await fetch(url, options);
const result = await response.text();
console.log(result);
} catch (error) {
console.error(error);
}
Join in the discussion - add comment below:
Could be useful to have something on the “Tutorials” page maybe, as there’s nothing there currently.
Yeah, thanks for the heads up, that’s good to know. I don’t think I have the ability to change that code as it’s auto generated by the platform unfortunately but I’ll look into it.
Thanks that worked!
But FYI, that isn’t included or mentioned in the code you can copy from here
You forgot JSON.stringify() around the body:
JSON.stringify({
liUrls: [
‘https://www.linkedin.com/company/hilton/’
]
})