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…
Thank you!