Hello all!
There are bits and pieces of documentation that relate to this topic, but none that explicitly show how to use this mutation from Python (that I’ve been able to find).
Basically, I’d like the query set up so that I have dynamic variables for both file (the image being uploaded) and item_id (the Item to which the image is uploaded to).
Does anyone have an example script showing how this is done? Here is what I’ve tried so far:
import requests
import json
import os
import pandas as pd
from pprint import pp
apiKey = os.getenv("MONDAY_API_TOKEN")
apiUrl = "https://api.monday.com/v2"
headers = {"Authorization" : apiKey}
url = "https://api.monday.com/v2/file"
payload = {'query': 'mutation add_file($file: File!, $item: ID!) {add_file_to_column (item_id: $item, column_id:"files__1" file: $file) { id } }'}
variables = {
'file': open('/path/to/my/file.svg', 'rb'),
'item_id': '6530743418'
}
payload['variables'] = variables
response = requests.post(url, headers=headers, data=payload)
pp(response.headers)
Appreciate any help.
Best,
-Kyle
