I’m trying to upload an image to a monday update using the add_file_to_update mutation.
I’ve referenced the following posts:
- Announcement: Uploading files to monday.com has just become easier :)
- Upload File using API and python and requests ( add_file_to_column)
With the help of those posts, I have the following code:
My code
import requests
import os
def add_file_to_update(update_id):
api_key = os.environ.get("MONDAY_API_KEY")
headers = {"Authorization" : api_key}
apiUrl = "https://api.monday.com/v2/file"
mutate_query = 'mutation ($updateId: Int!, $file: File!) { add_file_to_update (update_id: $updateId, file: $file) { id } }'
vars = {
'updateId' : int(update_id),
}
add_file = {'query' : mutate_query, 'variables' : vars}
dir_path = os.path.dirname(os.path.realpath(__file__))
files = [('variables[file]',('image.png',open(dir_path+'/image.png','rb'),'image/png'))]
r = requests.post(url=apiUrl, json=add_file, files=files, headers=headers)
The image.png file is a file that has no issues, as in I am able to open and view the file.
Unfortunately, I’m getting this error message, and I’m not sure how to debug the error.
Error message
{'error_message': 'Unsupported query', 'status_code': 400}
Does anyone have any idea where/what the issue is?




