Continually getting errors using LinkedIn API.
async function fetchAdData(access_token) {
const headers = {
'Authorization': `Bearer ${access_token}`,
'Linkedin-Version': '202401',
'Content-Type': 'application/json',
'X-Restli-Protocol-Version': '2.0.0'
};
const url = 'https://api.linkedin.com/rest/adAnalytics';
const data = {
q: 'analytics',
timeGranularity: 'ALL',
dateRange: {
start: {
year: 2021,
month: 1,
day: 1
}
},
facets: ['INDUSTRY'] // Include necessary facet(s) as per API requirements
};
let response;
try {
response = await axios.post(url, data, { headers });
return response.data;
} catch (error) {
console.error("Error details:", error.response ? error.response.data : error.message);
if (error.response && error.response.data.errorDetails && error.response.data.errorDetails.inputErrors) {
error.response.data.errorDetails.inputErrors.forEach(err => {
console.error("Input error code:", err.code);
console.error("Input error path:", err.input.inputPath);
});
}
}
}
Errors:
Error details: {
status: 404,
code: 'RESOURCE_NOT_FOUND',
message: 'No virtual resource found'
}
With the updates to the API, asking if there is something that is missing?
Tried various version of pinging Linkedin API to get advertising data.