Skip to main content

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 } }, ] }) });

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.

 


Oh well that's easy!