Uploading file with monday sdk from browser

I am new to monday apps framework and building a item view. I am trying to upload a file with monday sdk and using this code,

const query = `mutation add_file($update_id:Int!, $video: File!) {

    add_file_to_update(update_id: $update_id, file: $video) {
   
    id
    
    }
    
}`;
  monday.api(query, {
variables: {
  video: new File([blob], "video.mp4", {
    lastModified: new Date(),
    type: "video/mp4",
  }),
  update_id: 7894482,
},
  });

And this is the request i see going through in chrome developer tools and failing with 500 error. Can someone help me with this ?

Hey @arjun :wave:

That’s quite odd! I would recommend trying the same API call, but without specifying details about the file?

I would remove:

lastModified: new Date(),
    type: "video/mp4",

I would also try out removing [blob] from the variable. Could you try that out and let us know if it worked? Just to make sure as well, is the Update ID with the ID of 7894482 an update you can edit within the UI?

-Alex

It was so stupid of me. I was passing a wrong update id. Used a proper update id and it worked. Thank you for the help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.