Hello!
My app, which has been running for a few years, suddenly stopped uploading files. It seems that the upload via the v2/ endpoint stopped working. I have a client-side JavaScript app using fetch. It is a known example from this forum.
let query = `mutation add_file($file: File!) {
add_file_to_column (item_id: ${itemId}, column_id: "${columnId}", file: $file) {id}
}`;
const formData = new FormData();
formData.append("variables[file]", newFile, newFile.name);
formData.append("query", query);
let result = await fetch('https://api.monday.com/v2/', {
method: "POST",
body: formData,
headers: {
"Authorization": "APIToken"
}
});
I tried a few things that failed:
-
v2 endpoint: Monday returns CORS error “error type: cors, status: 500”.
-
v2/file endpoint: I got an error, but not from Monday, “Failed to fetch” and “has been blocked by CORS policy”.
-
via monday.api: It sends a request to the v2/ endpoint. I got a response from Monday, “status_code: 500, error_message: Internal server error”.
Then I tried in Chrome with --disable-web-security:
-
v2 endpoint: Monday returns error “type: basic, status: 500”.
-
v2/file endpoint: It works, files are uploaded. But of course, because of --disable-web-security, this is not a solution for the app.
-
via monday.api: Monday returns error “error_message: Internal server error, status_code: 500”.
I tried all this in different API versions, and with published versions with uploaded zip code.
Then I tried POSTMAN:
-
v2 endpoint, API-version 2024-10: I got “500 Internal Server Error”.
-
v2 endpoint, API-version 2024-07: I got the error “Variable $file of type File! was provided invalid value”, “Expected value to not be null”.
-
v2/file endpoint: File is uploaded!
My conclusion is that Monday disabled the v2 endpoint for uploading files. The v2/file endpoint is working fine, but because of the CORS issue, it cannot be used for client-side upload.
Maybe someone has the same issue or a solution for how to upload files client-side. I would be very grateful.
Just to add the monday.api code:
let query = `mutation add_file($file: File!) {
add_file_to_column (item_id: ${itemId}, column_id: "${columnId}", file: $file) {id}
}`;
this._monday.api(query, { variables: { file: newFile } })
.then(response => console.log(response))
.catch(error => console.error(error));