Help

Re: Populating a List/Multi-Select Field from the API without enum values

874 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Anthony_Wathen
4 - Data Explorer
4 - Data Explorer

Hi there.

So here’s my situation currently. I am working on an automated inventory of some tech infrastructure. Certain devices have a single serial number while others have multiple.

The multi-select type is nice but the values are typically a set of enum values that are already known. With the API, I’ve noticed I cannot define values in a multi-select field that have not already been created, hence when I attempt to create the record, it doesn’t work.

Is there a list/array-type field where I don’t need to have the values pre-defined?

An example API request:

{
    "fields": {
        "Hostname": "R1",
        "Mgmt IP": "192.168.1.1",
        "Model": [
            "recGWOZKSXAnmB6l3"
        ],
        "Network OS": [
            "rec1YsLAROLBIF02H"
        ],
        "Current Image": "sup-bootdisk:s72033-advipservicesk9-mz.122-33.SXI6.bin",
        "Current Software Version": "12.2(33)SXI6",
        "Login Status": "Successful",
        "Serial Numbers": [
           "abc123456jkl",
           "wpe204301spo"
        ]
     }
}
1 Reply 1

Although you can create a linked record on-the-fly when creating the "parent’ record in Airtable’s native interface, you are correct that you cannot do so using the API.

If you know that the linked record does not exist yet, you simply have to create the linked record first using the POST request (curl) or create method (JavaScript). Then use the returned record id when creating the parent record.

If the linked record might exist already, you can do a GET request (curl) or select method (JavaScript) with a filterByFormula string to see if the record already exists. If the record already exists, use the returned record id in the parent record. If the record does not yet exist, create it first.