Upload File using API and python and requests ( add_file_to_column)

Hi everyone!

I am trying to upload a file to an item using python and the requests library following the new guidelines described here: Announcement: Uploading files to monday.com has just become easier :), but I was not successful in doing so. If anyone could provide some insight to what I am doing wrong, I would greatly appreciate it!

My code:

    apiUrlFiles = "https://api.monday.com/v2/file"

    headers = {"Authorization": apiKey,
               "Content-Type": "multipart/form-data"}

    item_id = 1091467834
    column ='column'
    query = f'mutation ($file: File!)' \
            f'{{ add_file_to_column  ' \
            f' ( item_id:{item_id}, ' \
            f'column_id:"{column}", file: $file) ' \
            f'{{ id }} }}'

    with open('t.txt', 'rb') as f:

        data = {'query': query, 'map': {"t.txt": 'variables.file'}}
        file = {'t.txt': f}
        r = requests.post(url=apiUrlFiles,

error message:

{"error_message":"Unsupported query","status_code":400}


This worked for me.

import requests

url = “https://api.monday.com/v2/file
payload={‘query’: ‘mutation ($file: File!) { add_file_to_column (file: $file, item_id: XXXXX, column_id: “files”) {id }}’}
headers = {
‘Authorization’: ‘apikey’,
response = requests.request(“POST”, url, headers=headers, data=payload, files=files)

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