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,
json=data,
headers=headers,
files=file)
error message:
{"error_message":"Unsupported query","status_code":400}
Thanks!