Help

The Airtable Community will undergo scheduled maintenance on September 17 from 10:00 PM PST to 11:15 PM PST. During this period, you may experience temporary disruptions. We apologize for any inconvenience and appreciate your understanding.

Re: Creating a table with multipleRecordLinks Field with Rest API

Solved
Jump to Solution
1067 0
cancel
Showing results for 
Search instead for 
Did you mean: 
EricJ
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello Airtable people!

I am trying to use the Rest API through a python script to create a subcategories table with a multipleRecordLinks field that links to a category table. I am having the toughest time trying to create this field and decipher the error messages I am getting. I am hoping someone on this community can help me.

My first attempt looked something like this:
{
"description": "A list of all of the subcategories",
"fields": [
{
"name": "Category",
"options": {
"linkedTableId": "tblPyvCqwd50kh7P2",
"inverseLinkFieldId": "flduKctYyZ1ckgVxR",
"isReversed": false,
"prefersSingleRecordLink" : true
},
"type": "multipleRecordLinks"
},
{
"description": "Name of the subcategory",
"name": "Subcategory Name",
"type": "singleLineText"
},
{
"name": "Display Color",
"type": "singleLineText"
}
],
"name": "SubCategories"
}

And I get this error message saying that options that I've included are not included:
{'error': {'message': 'Invalid options for SubCategories.Category: Failed '
'schema validation: inverseLinkFieldId is not included '
'in the Category.options schema, isReversed is not '
'included in the Category.options schema, '
'prefersSingleRecordLink is not included in the '
'Category.options schema',
'type': 'INVALID_FIELD_TYPE_OPTIONS_FOR_CREATE'}}


I read this post (https://community.airtable.com/t5/development-apis/creating-a-linked-field-with-scriptin/td-p/98017) and tried to take out isReversed and prefersSingleRecordLink as suggested:

{
"description": "A list of all of the subcategories",
"fields": [
{
"name": "Category",
"options": {
"linkedTableId": "tblx441joiqxYei9L",
"inverseLinkFieldId": "fldlrQUYUD5zG3M0r"
},
"type": "multipleRecordLinks"
},
{
"description": "Name of the subcategory",
"name": "Subcategory Name",
"type": "singleLineText"
},
{
"name": "Display Color",
"type": "singleLineText"
}
],
"name": "SubCategories"
}

Here is the error I got, looks very similar to prior message. I am not sure what the difference between Category.0.options and Category.1.options are, but noted the error mentioned both.
{'error': {'message': 'Invalid options for SubCategories.Category: Failed '
'schema validation: Category.0.options.isReversed is '
'missing, Category.0.options.prefersSingleRecordLink is '
'missing, inverseLinkFieldId is not included in the '
'Category.1.options schema',
'type': 'INVALID_FIELD_TYPE_OPTIONS_FOR_CREATE'}}


Tried just taking out prefersSingleRecordLink because I found docs that said this can't be used when scripting tables.
{
"description": "A list of all of the subcategories",
"fields": [
{
"name": "Category",
"options": {
"linkedTableId": "tbl8DJjJBtgKtygF8",
"inverseLinkFieldId": "fldLtd9Gj4XjUQ049",
"isReversed": false
},
"type": "multipleRecordLinks"
},
{
"description": "Name of the subcategory",
"name": "Subcategory Name",
"type": "singleLineText"
},
{
"name": "Display Color",
"type": "singleLineText"
}
],
"name": "SubCategories"
}
{'error': {'message': 'Invalid options for SubCategories.Category: Failed '
'schema validation: '
'Category.0.options.prefersSingleRecordLink is missing, '
'inverseLinkFieldId is not included in the '
'Category.1.options schema, isReversed is not included '
'in the Category.1.options schema',
'type': 'INVALID_FIELD_TYPE_OPTIONS_FOR_CREATE'}}

 

1 Solution

Accepted Solutions
Alexey_Gusev
12 - Earth
12 - Earth

Hi,
- You should set only LinkedTableID option.
- You should choose other field type for primary

For example, that works

Alexey_Gusev_0-1687933103405.png

Alexey_Gusev_1-1687933278994.png

 

See Solution in Thread

2 Replies 2
Alexey_Gusev
12 - Earth
12 - Earth

Hi,
- You should set only LinkedTableID option.
- You should choose other field type for primary

For example, that works

Alexey_Gusev_0-1687933103405.png

Alexey_Gusev_1-1687933278994.png

 

EricJ
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you so much, Alexy! This worked. I very much appreciate the time you too to help me out!