Jul 19, 2023 08:09 AM
This seems like a very basic question but search hasn't yielded me an answer.
How do I set a field with spaces in the name using a fetch() request?
const res = await fetch('https://api.airtable.com/v0/xyz/Estimates', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.AIRTABLE_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
"records": [
{
"fields": {
Client: [client.id],
JSON: escapedJson,
Total: total,
Screens: screens,
Outside Only: flags.outsideOnly
}
},
]
})
});
Solved! Go to Solution.
Jul 19, 2023 08:23 AM - edited Jul 19, 2023 08:25 AM
Wrap the field name in double quotes
body: JSON.stringify({
"records": [
{
"fields": {
Client: [client.id],
JSON: escapedJson,
Total: total,
Screens: screens,
"Outside Only": flags.outsideOnly
}
}
]
})
I tend to just wrap all JSON params in quotes to save remembering when I'm supposed to.
Jul 19, 2023 08:23 AM - edited Jul 19, 2023 08:25 AM
Wrap the field name in double quotes
body: JSON.stringify({
"records": [
{
"fields": {
Client: [client.id],
JSON: escapedJson,
Total: total,
Screens: screens,
"Outside Only": flags.outsideOnly
}
}
]
})
I tend to just wrap all JSON params in quotes to save remembering when I'm supposed to.
Jul 19, 2023 10:08 AM
Oh well that's easy!