It is not possible to add a new row to the table using python

Hello!
I’m trying to add a row to a table using python, like this:

#Adding a new
row_data = {
'Organizer': ['JTP06oYrREypDLBxyzmBqQ'],
'Event start': '2023-17-05 10:00',
'Technical support': 'Required'
}
base.append_row('Applications board room', row_data)

but due to the fact that the columns to which I add values have the type: “Date”, “Single selection” and “Link to other records”, the values in my table turn out to be empty.
Help to make a query to the table correctly so that you can add records to these columns!

Hi @procoprobocop.

The append_row call seems to be correct. The date format ist ok I think. You just have to use the correct column names.

To add a link to an existing set of link for a row you have to use the add_link function: Links - SeaTable Programming Manual
To update a link mean to overwrite all other links and you have to use the update_link function: Links - SeaTable Programming Manual

I don’t understand your decision…
When I specify the date ‘2023-17-05 10:00’ to the column with the “Date” type, then the row where the date should be displayed is empty.
With links to other records, it is even more unclear where to find the “Link Table Identifier”? And where can I see the “Link column Key”? I only see the API token, but that’s not what I need

Regarding the date column you have to change the day and month value. IT has to be ISO conform.

100%

What you have to do is this:

  • Append the row without the data for the link column (hence remove the “Organizer” from your dictionary)
  • Use the _id of the just appended row to populate the link column in said row
1 Like

Thank you, yes, I was not attentive here

I add values to the string like this:

base.add_link('Full name', 'employees', 'Room', 'L4HosWGZQyWxLQzz-j1EhQ', 'F4BLJsCYS-SM-E_cnenF2w')
#Adding a new
row_data = {
    'Organizer': 'L4HosWGZQyWxLQzz-j1EhQ',
    'Event start': '2023-05-17 10:00',
    'Technical support': 'Required',
    'Duration': 7200,
    'Describe the event': 'This is a test record'
}
base.append_row('Applications board room', row_data)

but I still have all the lines filled in except “Organizer”

Please re-read this:

I did it all
Now, when executing the script, a new row appears in the table. In this line, all fields are filled in, except for the “Organizer” field, which has the “Link to other records” type.
How do I fill in this field?

Append the row THEN Update the link. Add_row returns the new row ID to be used in update_link.

1 Like

please tell me what’s wrong? I do everything according to the instructions

from seatable_api import Base, context
server_url = 'https://seatable.my_address.com '
api_token = 'TOKEN'
base = Base(api_token, server_url)
base.auth()
rows = base.list_rows('Collegium hall')
base.add_link('Organizer', 'Employees', 'Collegium Hall', 'L4HosWGZQyWxLQzz-j1EhQ', 'P7fq-xF9RBKNG2bfByhmFA')
base.update_link('Organizer', 'Employees', 'Collegium hall', 'L4HosWGZQyWxLQzz-j1EhQ', ['P7fq-xF9RBKNG2bfByhmFA'])
row_data = {
    'Event start': '2023-05-17 10:00',
    'Technical support': 'Required',
    'Duration': 7200,
    'Describe the event': 'This is a test record'
}
base.append_row('Applications of the collegium hall', row_data)

but I get an error:

raiseConnectionError(response.status_code, response.text)
Connection Error: [Errno 400] {"error_type":"table_not_exist","error_message":"table Employees or Collegium hall not found"}

Obviously, you do NOT.

I do not want to sound sarcastic, but which part of this error message don’t you understand? Without knowing a thing about your base, I can see the problem right away: “Collegium hall” is not the same as “Collegium Hall”.

Additionally, you keep ignoring my and @AkDk7’s advice. I told you and he seconded that you have to create the row first and then add the link.

1 Like

ok, here I have added a new line, a completely empty line:

from seatable_api import Base, context
server_url = 'https://my_seatable.com'
api_token = 'TOKEN'
base = Base(api_token, server_url)
base.auth()
rows = base.list_rows('Applications')
row_data = {
    'Organizer': "
}
base.append_row('Applications board room', row_data)

how do I add a link in the same request if I don’t yet know the id that the system assigned to the new line?

Now, base.append_row returns an object with the new row id. You have to put that value into the function call update_link.

The update_link function looks like that (Links - SeaTable Programming Manual):

base.update_link(
        link_id='r4IJ',
        table_name='Table1',
        other_table_name='Table2',
        row_id='BXhEm9ucTNu3FjupIk7Xug',
        other_rows_ids=[
          'exkb56fAT66j8R0w6wD9Qg',
          'DjHjwmlRRB6WgU9uPnrWeA'
        ]
    )

So you have to get the link_id (Links - SeaTable Programming Manual) of the linked column, add the new row id and the put the row id of the related record from the other table into the array of other_row_ids.

If you did everything correct, it should update the value.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.