Node POST to /api/run.json - Authentication credentials were not provided.
I
Ian Klek
started a topic
about 4 years ago
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
Best Answer
n
nestor
said
about 4 years ago
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
That's right it can also work as a url parameter. I'm glad it is working now.
I
Ian Klek
said
about 4 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.
nestor
said
about 4 years ago
Answer
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
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:
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
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
- Oldest First
- Popular
- Newest First
Sorted by Newest Firstnestor
That's right it can also work as a url parameter. I'm glad it is working now.
Ian Klek
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.
nestor
Apikey is not a data parameter. You should send authentication via Authorization header, or any basic auth method that Node libraries provide.
1 person likes this
-
Unable to select Scrapy project in GitHub
-
ScrapyCloud can't call spider?
-
Unhandled error in Deferred
-
Item API - Filtering
-
newbie to web scraping but need data from zillow
-
ValueError: Invalid control character
-
Cancelling account
-
Best Practices
-
Beautifulsoup with ScrapingHub
-
Delete a project in ScrapingHub
See all 445 topics