Please can someone help, because the most basic of tasks has turned into a nightmare. I've tried several node libraries to simply POST to /api/run.json to trigger a crawl but I get the creds not provided response.
Please could someone enlighten me how to how/if this is possible? It works fine from postman. Example code I used below:
constform=newFormData();
form.append('apiKey', "removed");
form.append('spider', "xxxx");
form.append('project', "12345");
fetch(this.SCRAPE_URL, { method:'POST', body: form })
.then(res =>res.json())
.then(json =>console.log(json));
Many thanks
0 Votes
nestor posted
about 5 years ago
AdminBest Answer
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
1 Votes
3 Comments
Sorted by
nestorposted
almost 5 years ago
Admin
That's right it can also work as a url parameter. I'm glad it is working now.
0 Votes
I
Ian Klekposted
about 5 years ago
Thanks nestor! i think postman will handle a parameter named apikey differently as it works with apikey in the body. How annoying! All working now...apikey can also be sent as a url parameter i discovered.
0 Votes
nestorposted
about 5 years ago
AdminAnswer
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
Please can someone help, because the most basic of tasks has turned into a nightmare. I've tried several node libraries to simply POST to /api/run.json to trigger a crawl but I get the creds not provided response.
Please could someone enlighten me how to how/if this is possible? It works fine from postman. Example code I used below:
form.append('apiKey', "removed");
form.append('spider', "xxxx");
form.append('project', "12345");
fetch(this.SCRAPE_URL, { method: 'POST', body: form })
.then(res => res.json())
.then(json => console.log(json));
Many thanks
0 Votes
nestor posted about 5 years ago Admin Best Answer
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
1 Votes
3 Comments
nestor posted almost 5 years ago Admin
That's right it can also work as a url parameter. I'm glad it is working now.
0 Votes
Ian Klek posted about 5 years ago
Thanks nestor! i think postman will handle a parameter named apikey differently as it works with apikey in the body. How annoying! All working now...apikey can also be sent as a url parameter i discovered.
0 Votes
nestor posted about 5 years ago Admin Answer
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
1 Votes
Login to post a comment