Fix for INVALID_VALUE_FOR_COLUMN for single line text column
This behavior started a couple weeks ago. Using Airtable’s airtable JS API v0.5.8, I used to be able to call update() successfully on table where the value for column to be updated was a javascript number.
Now it returns the error INVALID_VALUE_FOR_COLUMN. When I convert the number to a string before passing it into the update() call, it works.
Just a workaround FYI for others. It seems like is some stronger API checking going on on the Airtable server API side.
Page 1 / 1
Interesting—I wonder if this is a newly-introduced bug. Are you failing to update a number field with a number, or a number field with a string, or a text field with a number? (Or something else?)
Sample code and a description of the base would help us reproduce this so we can get this solved.
@Case_Larsen - is it possible you forgot to use the {typecast:true} feature in your recent calls?
Interesting—I wonder if this is a newly-introduced bug. Are you failing to update a number field with a number, or a number field with a string, or a text field with a number? (Or something else?)
Sample code and a description of the base would help us reproduce this so we can get this solved.
Here’s a repro case for a table with column “SingleLineText” which is of type single line text:
var Airtable = require('airtable')
var base = new Airtable({ apiKey: '<your key>' }).base('<your table id>')
base('Table 1').create({
'SingleLineText': 123
}, function (err, record) {
if (err) { console.error(err); return }
console.log('created', record.getId())
})
base('Table 1').create({
'SingleLineText': '456'
}, function (err, record) {
if (err) { console.error(err); return }
console.log('created', record.getId())
})
results in
created recc5jiGDbSGlpEsR
Class {
error: 'INVALID_VALUE_FOR_COLUMN',
message: 'Field SingleLineText cannot accept the provided value',
statusCode: 422 }
and resulting table having only one row with “456” in the SingleLineText column. i.e. the operation with 123 failed.
@openside I didn’t see typecast in the documentation, and it had been working for a few weeks already as-is, but good to know.
As said, i think it’s probably increased API strictness (not a bug) which is ok, and the original request submitted an integer, not a string value, so I’d still need to cast values to a string before adding the typecast directive.
We’ll look into whether this is a bigger issue, so thanks for bringing this to our attention.
It sounds like your issue has been solved, which is great! Let us know if you run into any other issues (or if I misunderstood and your issue isn’t solved).
Hi EvanHahn,
I have the same error today. The field type is Barcode (Named GTIN) and I have tried to insert the GTIN code (13 digits) as text and as number. The error is the same.
gdc
I chaged the field type to ```
SingleLineText
Hi EvanHahn,
I have the same error today. The field type is Barcode (Named GTIN) and I have tried to insert the GTIN code (13 digits) as text and as number. The error is the same.
gdc
Could you include a code snippet of your problem (without your API key!) and the exact error you’re receiving?
Could you include a code snippet of your problem (without your API key!) and the exact error you’re receiving?
Hi EvanHahn,
I found out why I had the problem with barcode field.
I didn’t realize before that, the “barcode” type field is an array with two elements, one “type” and another “text”.
I sugest that the error return array be more explanatory about the error and show the values received. This will help debug the problem. I saw that a lot of people asks about these API insert/replace errors.
Best
Hi EvanHahn,
I found out why I had the problem with barcode field.
I didn’t realize before that, the “barcode” type field is an array with two elements, one “type” and another “text”.
I sugest that the error return array be more explanatory about the error and show the values received. This will help debug the problem. I saw that a lot of people asks about these API insert/replace errors.
Best
We’ve thought about improving API error messages and will keep this in mind as we work on future versions—we’ll add this to the list. Thanks!
It works when you use the {typecast: true} parameter
example:
base(‘Deal’).create({
“Quantity”: 720,
“PaymentMethod”: “Cash”,
}, {typecast: true}, function(err, record) {
if (err) {
console.error(err);
return;
}
console.log(record.getId());
});
Interesting—I wonder if this is a newly-introduced bug. Are you failing to update a number field with a number, or a number field with a string, or a text field with a number? (Or something else?)
Sample code and a description of the base would help us reproduce this so we can get this solved.
Same error here.
Solved by adding "typecast": true and changing SingleLineText type to LongText
I wish this said: Field SingleLineText cannot accept the provide value… because e.g. its type ‘Object’ is incompatible with the ‘String’ type of the field. (or something like that).