Skip to main content

What's the mutation to add an externally-hosted file to a column?

  • April 18, 2024
  • 4 replies
  • 170 views

dvdsmpsn
Forum|alt.badge.img+1

I’ve been looking at the Files column type, and see that for external files hosted in say Google Drive, Box, Dropbox or Sharepoint, the files are described by a stringified version of the structure below:

{
	"files": [
		{
			"name": "Book.xlsx",
			"fileId": "c42b3230-42b3-42b3-42b3-9d6f7b2a081b",
			"fileType": "ONE_DRIVE",
			"createdAt": 1234,
			"createdBy": "456",
			"linkToFile": "https://someinstance-my.sharepoint.com/:x:/g/personal/username_someinstance_onmicrosoft_com/PlkJXFVMWpEV2cVApxt_H_EB6GH1viK96wa1-rEqGKjmpw"
		},
		...
	]
}

👉 What mutation would be required to add a file from an external provider such as Google Drive, Box, Dropbox or Sharepoint to a column?

This is not the normal “upload a file” mutation as described here by:

mutation {
  add_file_to_column (
    item_id: 1234567890, 
    column_id: "files", 
    file: YOUR_FILE
  ) {
    id
  }
}

or

curl --location 'https://api.monday.com/v2/file' \\                          
     --header 'API-Version: 2024-01' \\
     --header 'Authorization: thisisasecret' \\
     --form 'query="mutation($item_id: ID!, $column_id: String!, $file: File!) { add_file_to_column(item_id: $item_id, column_id: $column_id, file: $file) { id } }"' \\
     --form 'variables="{\\"item_id\\": 123456, \\"column_id\\": \\"files\\"}"' \\
     --form 'map="{\\"file\\":\\"variables.file\\"}"' \\
     --form 'file=@/Users/me/Pictures/MyCat.png'

It looks to be different, but is not documented anywhere I can see.


.
.
.

Aside: I’m seeing a 404 on the documentation examples here:

https://developer.monday.com/api-reference/changelog/add_file_to_column-mutation

It points to this:

https://developer.monday.com/api-reference/docs/columns-queries-1#add-a-file-to-the-file-column 

…rather than this:

https://developer.monday.com/api-reference/reference/assets-1#add-file-to-the-file-column

4 replies

dvdsmpsn
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • April 18, 2024

Oh, could it be as described in clearing-the-files-column, but by updating the JSON contained rather than clearing everything?

Update: No, that doesn’t seem to work 😦


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • April 21, 2024

Hello there @dvdsmpsn,

As of today, that can not be achieved (passing an external file from a different platform such as Google Drive or Box, to a files column via API).

Let me know if you have any other questions!

Cheers,
Matias


dvdsmpsn
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • April 21, 2024

@Matias.Monday Please confirm – this is a private API available only to monday.com?

What workaround would you use instead?

  • Add a Link/URL column and populate that with an individual link to said external file (on Google Drive, Box etc)?

Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • April 24, 2024

Hello again @dvdsmpsn!

The workaround for this would be as you said to add a URL to a link column.