Node POST to /api/run.json - Authentication credentials were not provided.

Posted about 5 years ago by Ian Klek

Post a topic
Answered
I
Ian Klek

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:


 

const form = new FormData();

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

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

Sorted by
nestor

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

I

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

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