Nov 07, 2023 03:37 PM
Hello there, I'm trying to write data from one base to another through Airtable's API. My JSON is something like this:
let body = {
"fields":{
"prod_serv_cia_id": inputConfig.cia_id[0],
"NroParte": inputConfig.codigo[0],
"DescripCorta": inputConfig.descrip[0],
"DescripLarga": inputConfig.descrip[0],
"Marca": inputConfig.marca[0],
"Cantidad": inputConfig.disp[0],
"Costo": inputConfig.costo[0],
"AlmacenesScript": inputConfig.cia[0],
"StatusProducto":[
{ "id": "selq********yr", "name": "1. Producto seleccionado" }
],
"typecast": true
},
}
And the response I'm getting from the Airtable's API is:
{error: Object}
error: Object
type: "INVALID_VALUE_FOR_COLUMN"
message: "Cannot parse value for field StatusProducto"
The "StatusProducto" field is:
{id: "fld*******j9", name: "StatusProducto", description: "", type: "singleSelect", options: Object…}
id: "fld*******j9"
name: "StatusProducto"
description: ""
type: "singleSelect"
options: Object
isComputed: false
So, what can I do with that field in order to send the JSON correctly and write a new record in that Single Select field? Thanks in advance for your help!
Jul 24, 2024 03:37 PM
Hi,
It seems that quite some time has passed without anyone answering your question...
I was struggling with the same issue but using Python script and pyairtable package. No matter how you declare your JSON object it will fail raising INVALID_VALUE_FOR_COLUMN when using 'api.table' method if you have a single select field...
I just gave a try to pyairtable.orm module and now it is working...
Just an example of what I did:
from pyairtable.orm import Model, fields as F
class Logs(Model):
status = F.SelectField('Status')
start = F.TextField('Start')
end = F.TextField('End')
duration = F.TextField('Duration')
notes = F.TextField('Notes')
class Meta:
base_id = "YOUR_BASE_ID"
table_name = "YOUR_TABLE_NAME"
api_key = "YOUR_API_KEY"
new_log = Logs(
status = 'InProgress', # Possible Values: InProgress | Done | Failed
start = 'Date Here',
end = 'Date Here',
duration = 'Date Here',
notes = 'Date Here',
)
new_log.save()
print(new_log.id)
I hope that it could help anyone facing the same issue...