I am trying to use apify to get a websites title but when I run the code I get error 403, anyone know a fix?
My Code:
currentLink = "https://medium.com/vice/scientists-monitored-631-people-as-they-died-this-is-what-they-found-2de48ad9ed96";
const postUrl = "https://api.apify.com/v2/actor-tasks/LdLPzP6nopWgexrqX/run-sync-get-dataset-items?token=" + token;
var values = {
contentType: "application/json",
"startUrls": [{
"url": currentLink,
}]
};
$.ajax({
url: postUrl,
method: 'POST',
dataType: 'json',
data: JSON.stringify(values),
success: function(response) {
console.log(response.data); // Actor run object
getItemsFromDataset(response.data.defaultDatasetId);
}
});
I get this as my error: Failed to load resource: the server responded with a status of 403 () attached with a link that shows me the correct results.
You're using run-sync-get-dataset-items
endpoint, which returns dataset (and only dataset, i.e. the items array, not the run object). Then you're trying to get the items, assuming you're providing defaultDatasetId
, which is undefined
in this case. In the end, you get an error. This would also explain why you see the items via the link.
Not sure why it's error 403, not 404, but I don't see the implementation of getItemsFromDataset(). Could you please check the above first?