API : Update a row by adding another file to a file cell

Have you read and followed the instructions at: *READ ME FIRST* Technical Help FAQs - #2 by nigel ?

Answer: I did

How have you self-hosted Baserow.

Via docker container, on Ubuntu

Which version of Baserow are you using.

1.12.1

How have you configured your self-hosted installation?

sudo docker run
-d
–name baserow
-e BASEROW_PUBLIC_URL=http://vision.axe.lan:3001
-e DATABASE_HOST=10.0.0.123
-e DATABASE_NAME=baserow
-e DATABASE_USER=baserow
-e DATABASE_PASSWORD=xxxxxxxxxx
-e DATABASE_PORT=5432
-e EMAIL_SMTP=True
-e EMAIL_SMTP_HOST=176.57.240.1
-e FROM_EMAIL=baserow@xxxxxx.xx
-v baserow_vol:/baserow/data
-p 3001:80
–restart unless-stopped
baserow/baserow

Describe the problem

Hi Baserow community !

I have successfuly uploaded a file to a row using the python API. However I couldn’t figure out how to add up files in a single row. Everytime I patch the row, the previous file is being replaced with the new one.

I’m using this function

def basrw_update_row(
        collaborateur: str = "", 
        row_id: str = "", 
        data = ""):
    token = "QRu6Gu7g7S4gD..."
    url = f"http://vision.axe.lan:3001/api/database/rows/table/371/{row_id}/?user_field_names=true"
    response = requests.patch(
        url = url,
        headers={
            "Authorization": f"Token {token}",
            "Content-Type": "application/json"
        },
        json={
        "Collaborateur": f"{collaborateur}",
        "Fichiers": [data,]
        }
    )
    return response.text

How many rows in total do you have in your Baserow tables?

3 :smile:

Hi,

If you patch a record, you overwrite the values of all fields mentioned in the body of the request.

To add a file, you first need to perform a request.get() operation. This returns a list of files that are already added to the record. Add the new file to the list pass this updated list in the patch request.

Crystal clear, thank you Frederik