Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Dec 06, 2019 03:47 PM
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?
Dec 08, 2019 09:24 AM
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.
Dec 09, 2019 09:49 AM
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.
Dec 09, 2019 09:54 AM
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.
Dec 09, 2019 10:15 AM
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
}
}
Dec 09, 2019 01:44 PM
@Dev_Local, glad to hear you got it working. I’ve revised your list of things to do to get stuff working:
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:
remove typecast, don’t use it unless there is a good reason to use it
remove the quotes on the value being passed “TRUE”, “FALSE” (if - and ONLY if - the target field requires a boolean value)
just pass (all lower case) true or false (if - and ONLY if - the target field requires a boolean value)
Dec 10, 2019 09:17 AM
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.
Mar 19, 2021 10:04 AM
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
}
Nov 13, 2022 10:20 PM
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
Nov 13, 2022 10:43 PM
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"
]
}
}
]
}