Skip to main content

Linked records in API call

  • October 11, 2024
  • 2 replies
  • 29 views

Forum|alt.badge.img+4
  • New Participant
  • 1 reply

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

kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6004 replies
  • October 11, 2024

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

 


Forum|alt.badge.img+4
  • Author
  • New Participant
  • 1 reply
  • October 14, 2024

Thanks for your answers, it works now


Reply