Hey Everyone!
I’m sorry for making a duplicate of my old post, but this one is a bit different.
I found out that there’s now a SDK way of file upload rather than having an authentication flow which is what I have now. I was excited to implement it, so I updated the package to: "monday-sdk-js": "^0.1.2",
but I ran into some issues.
When trying to upload a file with the sdk I get:
Error: Invalid content-type on response from monday api graphql
at client.js:117
at client.js:137
at Array.forEach (<anonymous>)
at MondayClientSdk._receiveMessage (client.js:135)
This is for the add_file_to_update mutation. The update ID is indeed an Integer and file is a file, but maybe the file isn’t set up properly for upload?
This is the file when I console log it:
{file: File, name: "uploaded-file", ext: ".png"}
ext: ".png"
file: File
lastModified: 1585754352396
lastModifiedDate: Wed Apr 01 2020 11:19:12 GMT-0400 (Eastern Daylight Time)
__proto__: Object
name: "donot1.png"
size: 2250079
type: "image/png"
webkitRelativePath: ""
__proto__: File
name: "uploaded-file"
My mutation is written like this:
const fileMutation = `mutation add_file($update_id:Int!, $file: File!) {
add_file_to_update(update_id: $update_id, file: $file) {
id
}
}
`;
const variables = { file, update_id: parseInt(updateID) };
try {
monday.api(fileMutation, { variables })
.then((res) => {
if (res) {
console.log(res);
}
})
.catch((err) => console.log(err));
} catch (err) {
console.log(err);
}
I hope I’m not misunderstanding the new feature post as this feature was definitely needed for me. I currently have it working with a simple post request using the mutation using user’s token obtained from an auth flow. I would love to negate that extra step. I hope I can get someone to help me with this new awesome feature. Thank you in advance!