Help

Where to add: "typecast": true (when column type is checkbox)?

Topic Labels: API
13793 11
cancel
Showing results for 
Search instead for 
Did you mean: 
Dev_Local
6 - Interface Innovator
6 - Interface Innovator

I changed a column in Airtable from text to a checkbox (I am filling in with TRUE/FALSE (all caps)).

Now I get this when I try to insert:

  data: {
    error: {
      type: 'INVALID_VALUE_FOR_COLUMN',
      message: 'Field "Active" cannot accept the provided value'
    }
  }

I have seen articles saying to add:

"typecast": true

but this does not work. I’m not sure that I’m adding after the right curly bracket, as none of the articles I read are explicit on this, other than ‘add “typecase”: true’ somewhere.

I don’t know whether to add it after each fields entry like so, or somewhere else?

 {
   "fields": 
	{
		"key": "value",
		"key": "value"
	}, "typecast": true
 },

It is obviously being added in the wrong place, I am getting:

  data: {
    error: {
      type: 'INVALID_REQUEST_BODY',
      message: 'Could not parse request body'
    }

Is there an example JSON that anyone can share that has been successfully used here?

11 Replies 11

That looks [somewhat right except for that trailing comma seems out of place. But without seeing the actual payload in context that’s being sent in the API request, it’s difficult to say much. Often, errors are not what they seem.

I tried this again, looking at the placement of everything, and did find one correction that I made to reflect what I posted above.

I am still getting failures, but this time something different. I sent the JSON through a JSON validator, and it all checks out:

Sending: (this is cut-n-paste from my IDE, what I am sending - only key/value names have been changed, nothing else:

{ 
   "fields":{ 
      "key":"value",
      "key":"value"
   },
   "typecast":true
}

and I get back:

  data: {
    error: {
      type: 'INVALID_REQUEST_UNKNOWN',
      message: 'Invalid request: parameter validation failed. Check your request data.'
    }

The trailing comma in the original post is a separator for the next record, and would be needed if there is another record (set of fields) that follows (am sending 10 at a time), I strip off the last comma on the last record.

So Airtable does not like the placement of "typecast": true as is presented above, I’m not sure where it goes, or if it’s intended to work, but just does not work in this version of the API.

In my latest test, I am sending only one record (one set of fields), and getting this error.

This is probably not necessary as I think the JSON standard is to allow these trailing commas. But, until we’re sure the commas are not the issue, probably best to tidy the payloads.

Careful - the error is a bit more ambiguous than that. It doesn’t actually say that Typecast is the issue. As I said above - without seeing the actual payload in context that’s being sent in the API request, it’s difficult to say much.

Before I changed the column to a checkbox, I was passing “TRUE” or “FALSE” all upper case with quotes, and then began to play with typecast, never got anything to work.

After much experimenting, I got this to work by doing three things:

1. remove typecast, don't use it, delete it
2. Remove the quotes on the value being passed "TRUE", "FALSE", 
3. just pass (all lower case) true or false

==> Passing upper case TRUE or FALSE as a boolean value fails,
==> Passing as String (enclosed in quotes) fails.

It works like so:

{ 
   "fields":{ 
      "key1": "value",
      "key2": true,
      "key3": false
   }
}

@Dev_Local, glad to hear you got it working. I’ve revised your list of things to do to get stuff working:

  1. always share the exact payload that’s triggering the issue because other members will likely spot issues such as “TRUE” passed as a boolean value and save you big headaches. :winking_face:

  2. remove typecast, don’t use it unless there is a good reason to use it

  3. remove the quotes on the value being passed “TRUE”, “FALSE” (if - and ONLY if - the target field requires a boolean value)

  4. just pass (all lower case) true or false (if - and ONLY if - the target field requires a boolean value)

Thank you, I did try to be as thorough as possible in my original question/post.

Your initial comments were helpful and led to the solution, it put the thought in my mind to look at all possible things that could be wrong instead of focusing on typecast, and I quickly saw the issue.


Others have posted in the community forum with similar issues, and it was the answers and thread there that led me to thinking I needed typecast.

There was never a final resolution on the posted issue of what ultimately worked, misleading and dead end.

If I post, (or anyone does), the final resolution, as was done here, would be super helpful to others. Thank you.

I was struggling with making this work (using requests).
I found that placement as follows works:
{
“records”:[
{
“fields”:{
“Key”:“value”,
“Key”:“value”,
“Key”:“value”
}
}
],
“typecast”:true
}

Scott_Heliker
6 - Interface Innovator
6 - Interface Innovator

None of these have worked for me. What is the final resolution? Tring to pass multi-select items and make new ones if it does not exist. Same I have read the docs to pass “typecast”:true but does not work.

{
  "records": [
 {
      "id": "re************vMpe",
      "fields": {
        "Contact ID": "555555",
        "Firtst Name": "Tom",
        "Last Name": "Doe",
        "Work Flow": [
          "red",
          "blue",
          "green"
        ]
      }
    }
  ],
“typecast”:true
}

Could not parse request body

Using this way give this error

{
	"records": [{
		"id": "rec7MS***********Mpe",
                "typecast": true,
		"fields": {
			"fldkjv8F8evjeCOqM": "555555",
			"fldvlUpvSh4K2M9CU": "Tom",
			"fldD0kTU2ffnzLp0k": "Doe",
			"fldJUQxE25EYTfFZY": [
				"red",
				"green"
			]
		}
	}]
}

Could not parse request body

Scott_Heliker
6 - Interface Innovator
6 - Interface Innovator

Looks like has to go at the very top after trying everything else. But how can we delete an option from a selection? Looks like this just ad an item if it’s not there to update a specific record but not an endpoint to just add or remove options from multi-select field.

{
    "typecast": true,
    "records": [
        {
            "id": "rec7M******vMpe",
            "fields": {
                "fldkjv8F8evjeCOqM": "555555",
                "fldvlUpvSh4K2M9CU": "Tom",
                "fldD0kTU2ffnzLp0k": "Doe",
                "fldJUQxE25EYTfFZY": [
                    "Review Us",
                    "Post Sale",
                    "green"
                ]
            }
        }
    ]
}