Help

Re: Linked records in API call

338 0
cancel
Showing results for 
Search instead for 
Did you mean: 
k6no
4 - Data Explorer
4 - Data Explorer

Hello,
I'm trying to run a script from BaseA to create a new record in BaseB. The new record in BaseB has a linked field, I followed this convention to reference it: Field_Name: [{id: record_id}]. I get INVALID_RECORD_ID error, though I've double-checked it and the record id is correct. What am I doing wrong?

 

let createRecordInBaseB = await fetch(
  `https://api.airtable.com/v0/${targetBaseId}/${targetTableId}`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${baseARecord.pat}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      fields: {
        "👀 Projects": [{id: projectRecordId}],
      },
    }),
  }
);

 

  

2 Replies 2

When using the web API, the cell value for a linked record field is an array of record IDs, not an array of objects.

https://airtable.com/developers/web/api/field-model#foreignkey

kuovonne_0-1728659769466.png

 

k6no
4 - Data Explorer
4 - Data Explorer

Thanks for your answers, it works now