I was able to successfully upload a file to a column using the following python code, using the requests library. Fair warning, here be dragons.
item_id = 12345678 #example only
f = 'file-path/file-name.ext'
q = f"""
mutation add_file($file: File!) {{
add_file_to_column (item_id: {int(item_id)},
column_id: files,
file: $file
){{
id
}}
}}
"""
files = {
'query': (None, q, 'application/json'),
'variables[file]': (f, open(f, 'rb'), 'application/octet-stream', {'Content-Transfer-Encoding': 'binary'})
}
r = requests.post(
url='https://api.monday.com/v2/file',
headers=headers,
files=files
)
One thing worth noting is you cannot pass other variables to the request, if you are also passing a file. I had to use string interpolation in order to pass the item_id to make it work.
I was also able to reproduce this issue in JavaScript as well.
Though my issue was worked around, I would be interested to know why this issue exists. Is this expected behavior according to the spec?