Query add_file_to_column: Unsupported query

Hey,
I’am currently working with n8n workflows and try to upload a file to a monday item column. Unfortunately it’s a pretty tough task as the error messages aren’t very detailed..

My last try returned an error 400 with “error_message”:
“Unsupported query”.

Maybe someone see the problem in my code and can give me a hint? :confused: I’am working on this for hours now.. pretty frustrating.

const fetch = require('node-fetch');
const { Blob } = require("buffer");

// set auth token and query
//API-KEY removed for safety reasons
var API_KEY = "YOUR-API-KEY"

//set query
var query = 'mutation ($file: File!) {add_file_to_column (file: $file, item_id: "'+$('Extract Monday IDs from path').first().json.itemid+'", column_id: "'+$('Filter2').first().json.id+'") { id } }';

// set URL
var url = "https://api.monday.com/v2/file";

//Create blob from binary data
const uploadFile = new Blob([$('Code').first().json.binaryFile.data.data], { type: $('Code').first().json.binaryFile.data.mimeType });

//Create Formdata
var formData = new FormData();
// Set the query
formData.append('query', query);
// Set the map (this is crucial for file uploads)
formData.append('map', JSON.stringify({"image": "variables.file"}));
// Add the file with the correct field name
formData.append('image', uploadFile, $('Code').first().json.binaryFile.data.fileName);

console.log(formData);
// FormData {
//     query: 'mutation ($file: File!) {add_file_to_column (file: $file, item_id: "8629869934", column_id: "datei__1") { id } }',
//     map: '{"image":"variables.file"}',
//     image: File {
//       size: 7556064,
//       type: 'image/jpeg',
//       name: 'filename.jpg',
//       lastModified: 1741961715020
//     }
//   }

// construct request options
var options = {
    method: 'post',
    headers: {
        "Authorization" : API_KEY,
        
// fetch will set it correctly with the boundary
    },
    body: formData
};

// make request
const rq = await fetch(url, options);
const rqjson = await rq.json();

return rqjson;

You get some different solutions froms google but none of them really helped me or work for me.

Greetings,
Max

I have been able to solve the problem in the meantime, so this thread can be closed :slight_smile: Finally I was able to create a simple HTTP request in n8n, previous attempts always resulted in a code 500, but this was due to incorrect test data.

Hey @MonWe,

Welcome to the community!

I’m glad you were able to resolve this. Moving forward, you can also open a support ticket here if you don’t get a quick response here. Our technical team can take a closer look at your specific query and help troubleshoot!

Best,
Rachel