Help

Re: WebAPI - Addressing field name with spaces in Fetch() request

Solved
Jump to Solution
1555 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Janssen
5 - Automation Enthusiast
5 - Automation Enthusiast

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

Accepted Solutions
Jack_Manuel
7 - App Architect
7 - App Architect

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.

 

See Solution in Thread

2 Replies 2
Jack_Manuel
7 - App Architect
7 - App Architect

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.

 

Janssen
5 - Automation Enthusiast
5 - Automation Enthusiast

Oh well that's easy!