ERR_INVALID_ARGUMENT Help !

I have this code, I'm using Puppeteer to scrape in API and I have to do the first request to an endpoint. Here is the code :
var firstRequest = new Request({
url: 'https://www.example.com/api/commerce/v1/categories',
headers: {
'Host': 'www.brownsfashion.com',
'Accept': 'application/json, text/plain, */*',
'Referer': 'https://www.example.com/',
'FF-Country': 'CA',
'FF-Currency': 'CAD',
},
})

await crawler.addRequests([firstRequest])
var firstRequest = new Request({
url: 'https://www.example.com/api/commerce/v1/categories',
headers: {
'Host': 'www.brownsfashion.com',
'Accept': 'application/json, text/plain, */*',
'Referer': 'https://www.example.com/',
'FF-Country': 'CA',
'FF-Currency': 'CAD',
},
})

await crawler.addRequests([firstRequest])
And here is the error log:
WARN PuppeteerCrawler: Reclaiming failed request back to the list or queue. net::ERR_INVALID_ARGUMENT at https://www.example.com/api/commerce/v1/categories
{"id":"SFR0x1KhOJkxLjo","url":"https://www.example.com/api/commerce/v1/categories","retryCount":1}
WARN PuppeteerCrawler: Reclaiming failed request back to the list or queue. net::ERR_INVALID_ARGUMENT at https://www.example.com/api/commerce/v1/categories
{"id":"SFR0x1KhOJkxLjo","url":"https://www.example.com/api/commerce/v1/categories","retryCount":1}
1 Reply
fair-rose
fair-rose3y ago
Hey NeoNomade, this is because you are explicitly setting the host header which is not allowed by chromium.

Did you find this page helpful?