
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 26, 2021 04:27 PM
I’m developing an API on Node.js + express on Heroku, and every time I fetch anything with POST, I get a 400 Bad request error.
Postman requests to the same endpoint work perfectly. So the only hypothesis I have is that I need a ‘Host’ header in my Airtable request (when I remove the ‘Host’ header in Postman. I get the same 400 Bad request error), but I don’t know what this ‘Host’ header should be.
To reproduce:
- Create a simple Node.js+express app on Heroku where you return the same body as you get:
app.post('/', (request, response) => {
response.status(200).send(request.body);
})
- Create Airtable automation with fetch (or an app with remoteFetchAsync):
let response = await fetch('https://....herokuapp.com/api/', {
method: 'POST',
body: JSON.stringify('Hello World!'),
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Accept': 'application/json'
},
});
console.log(await response.text());
You’ll get a ‘400 Bad Request’ response.
Solved! Go to Solution.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 27, 2021 07:59 AM
Solved!
I had to add 'Host': 'https://*.airtableblocks.com'
header.
await remoteFetchAsync('https://....herokuapp.com/api/', {
method: 'POST',
body: requestBody,
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Host': 'https://*.airtableblocks.com',
'Accept': 'application/json'
},
})

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 27, 2021 07:59 AM
Solved!
I had to add 'Host': 'https://*.airtableblocks.com'
header.
await remoteFetchAsync('https://....herokuapp.com/api/', {
method: 'POST',
body: requestBody,
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Host': 'https://*.airtableblocks.com',
'Accept': 'application/json'
},
})
