I am using a react app to upload a file in it and then want to save it to Monday using api. I have tried it by using Monday SDK.
-------------------Code starts-------------------------
let query = mutation { add_file_to_column (item_id: 1867830321, column_id: "files", file: C:/Users/HP/Downloads/googleDocsLogo.png) { id } };
monday.api(query)
.then(res => { console.log('res is '+JSON.stringify(res)) })
.catch(error => { console.log('error is '+error) })
-------------code ends-----------------
I have tried using fetch request as well but there getting ‘cors’ issue.
dvdsmpsn
(David @ David Simpson Apps)
May 14, 2024, 10:11am
2
@YuvrajSinghRajput I doubt very much that you can just specify a location on your HDD and hope for the best. You’ll need to add the content of the file to the request and post it to https://api.monday.com/v2/file.
If CORS is a problem that suggests you’re doing this client side, you’ll probably want some server side code to perform this operation.
Take a look at this example for clues:
Hello there @effex07 ,
That is quite strange, I just used exactly this (with a png image) and it worked well:
import fs from 'fs';
import fetch from 'node-fetch';
// adapted from: https://gist.github.com/tanaikech/40c9284e91d209356395b43022ffc5cc
// set filename
var upfile = 'images.png';
// set auth token and query
var API_KEY = "MYAPITOKEN"
var query = 'mutation ($file: File!) { add_file_to_column (file: $file, item_id: 1111111, column_id: "files") { id } }';
// set URL and boundary
var u…
dvdsmpsn
(David @ David Simpson Apps)
May 14, 2024, 10:17am
3
@YuvrajSinghRajput Or have a look at this:
I just wanted to update on my quest regarding file upload through the client side!
Monday.api() was unsuccessful, but I attempted to try again with a normal post request and I was met with a CORS problem. CORS issue when uploading file with API v2
I was still getting a CORS problem for /v2 and /v2/file endpoint, but I remembered a post saying /v2 was fixed so I figured I should give it a shot with a published build rather than a custom URL where my origin is https:…ngrok.io.
It works for /v2 …