Hello!
3 days ago my tool was working perfectly, when I uploaded the image to it, it used my own API that is connected to Monday, to send the image to a Monday table. It fetches automatically the ID of the table, and the ID of the column is always the same. I am running it like this, on my API:
app.post('/upload-file', upload.single('file'), async (req, res) => {
if (!req.file) {
return res.status(400).send('No file uploaded.');
}
// Extract partId from the query string
const partId = req.query.peca; // This is the board / table ID, it is available on the URL
if (!partId) {
return res.status(400).send('Part ID is missing.');
}
const formData = new FormData();
// GraphQL mutation with a variable for the file
const mutation = `
mutation ($file: File!) {
add_file_to_column (item_id: ${partId}, column_id: "arquivos", file: $file) {
id
}
}
`;
// Append the mutation and the file to the formData
formData.append('query', mutation);
formData.append('variables[file]', fs.createReadStream(req.file.path), {
filename: req.file.originalname,
contentType: req.file.mimetype,
});
try {
const response = await fetch('https://api.monday.com/v2/file', {
method: 'POST',
body: formData,
headers: {
...formData.getHeaders(),
'Authorization': 'MONDAY_API_KEY',
'API-Version': '2023-10'
},
});
const result = await response.json();
if (result.data) {
logWithTimestamp('File uploaded successfully to Monday.com', result);
res.send('File uploaded successfully');
} else {
logWithTimestamp('Error uploading file to Monday.com', JSON.stringify(result.errors));
res.status(500).send('Error uploading file to Monday.com');
}
} catch (error) {
logWithTimestamp('Error in file upload', error.message); // Log the error message
res.status(500).send('Error in file upload');
} finally {
fs.unlink(req.file.path, (err) => {
if (err) logWithTimestamp('Error deleting file:', err);
});
}
});
It stopped working from a day to the other, did something change? Am I doing something wrong? It always returns “Unsupported query” now…
Hello David, thank you very much for your answer, means a lot.
Makes a lot of sense, but even if I remove the version from there (like the Postman call from the Postman collection), it still has the same output, with or without version
It’s weird because there is another user here with problems using add_file_to_column… It was working just perfectly a few days ago, and suddenly, it stopped working… I really really would appreciate any help, and wouldn’t mind sharing more details if needed, after hours and hours and hours of debugging, I really don’t know what to do anymore.
Already created sample Node.js scripts to try to query it, making it every way possible, and everytime I just keep getting 400 Unsupported Query…
I am not sure I understand the question. The API version in this case is irrelevant since the same mutation works for all present API versions and it works with the 2024-01 (current version)