@dlicc – The unsupported query error is super weird; I was able to reproduce it and don’t really know what the reason is. But I got it to work in apps script!
Try this:
function uploadFileFetch() {
var url = "https://api.monday.com/v2/file";
var form = {
query : 'mutation ($file: File!, $item: ID!) { add_file_to_column (file: $file, item_id: $item, column_id: "files") { id } }',
variables: JSON.stringify({"item" : "373547130"}),
map: JSON.stringify({"file":"variables.file"}),
file : DriveApp.getFilesByName("test.txt").next().getBlob()
};
var options = {
method : "POST",
payload : form,
headers : {
'Authorization': 'eyJhbGciOiJIUzI1NiJ9.thisisasecret',
'API-Version' : '2024-01'
}
};
var request = UrlFetchApp.getRequest(url,options); // (OPTIONAL) generate the request so you
console.info("Request payload: " + request.payload); // can examine it (useful for debugging)
var response = UrlFetchApp.fetch(url,options);
console.info("Response body: " + response.getContentText());
}
It also works if you put the item ID in the query itself (instead of using the variables object).
Thanks for the attention @dipro ! Unfortunately, I’m still getting the same error using your script (with my API key and item id of course).
Exception: Request failed for https://api.monday.com returned code 500. Truncated server response: <!doctypehtml><html><head><style>@font-face{font-family:Roboto;font-style:normal;font-weight:500;font-display:swap;src:url(data:font/woff2;base64,d... (use muteHttpExceptions option to examine full response)
All of my other API calls are still working fine right now as well.
Just tried again and it worked for the first time! Maybe something intermittent going on with the API for file upload? … I will keep going and report back on further API calls of this type…