Using FormData in scripts

Topic Labels: Scripting extentions
1753 2
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer


I’m getting an error when I try to use create a Javascript FormData object in preparation for posting to an API. I would have thought FormData would have been well supported.

console.log(`Hello, ${}!`);
const endPoint = new URL('');
const formData = new FormData();
formData.append("user", 'tom');

const response = await fetch(endPoint.toString(), {
    method: "POST",
    body: formData,


Getting an error saying that FormData is not defined

2 Replies 2
4 - Data Explorer
4 - Data Explorer

They mention in their docs that the FormData API is not available in Airtable Scripting: Airtable Scripting

5 - Automation Enthusiast
5 - Automation Enthusiast

To use formData you can build the object yourself using:

let data = {
    key1: 'value1',
    key2: 'value2'

// Encoder les paramètres en format x-www-form-urlencoded
let formData = Object.keys(data).map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key])).join('&');

await fetch('URL_DE_VOTRE_API', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
    body: formData