Skip to main content

Hey !

I wanted to point out an issue in the Assets upload api documentation that I’ve encountered while building an integration.

Specifically in this section


In the graphQL and curl example, it is mentioned to use “files” for the column_id

However using this column_id will result in a 500 error


curl --location 'https://api.monday.com/v2/file' \\
--header 'Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \\
--header 'API-version: 2023-10' \\
--form 'query="mutation ($file: File!) {
add_file_to_column (file: $file, item_id: 7655999011, column_id: \\"files\\") {id}}"' \\
--form 'map="{\\"image\\":\\"variables.file\\"}
"' \\
--form 'image=@"/Users/sylvainb/downloads/large-marc.jpg"'

{"status_code":500,"error_message":"Internal server error","error_code":"INTERNAL_SERVER_ERROR"}%

Despite that error code, the file is still being uploaded to the file, however on top of throwing an error in my code, it prevents me from getting the id of the asset that was uploaded.


In order to circumvent this issue, I inspected the network calls of the webapp and realized that it was using the “files__1” for the column_id.

This solution was successfull:


curl --location 'https://api.monday.com/v2/file' \\
--header 'Authorization:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \\
--header 'API-version: 2023-10' \\
--form 'query="mutation ($file: File!) {
add_file_to_column (file: $file, item_id: 7655999011, column_id: \\"files__1\\") {id}}"' \\
--form 'map="{\\"image\\":\\"variables.file\\"}
"' \\
--form 'image=@"/Users/sylvainb/downloads/large-marc.jpg"'

{"data":{"add_file_to_column":{"id":"1735828653"}},"account_id":6498124}%


Later i found out that this column_id was mentioned in the python example of the doc 🙂


Thank you !


PS: The postman template also has this error.

Hi @sylvainb,


Welcome to the community!


Thanks for reaching out. Column IDs are unique to each board, so the example column ID may not be the same as the column ID you have on your board.


Let us know if you have any questions!


Best,

Rachel


Hey rachel !

I’m sorry but what you are saying does not seem to be true.

When you create a whole new board and add a “file” column



Its id is by default files__1


It also doesn’t change the fact that an upload using the “files” column_id, why I assume corresponds to the file gallery of an item is successfull while returning a 500 error !


Thanks 🙂


Hey @sylvainb!


The column ID is a unique identifier for a specific column on a specific board.


Before updating any column (files or otherwise), you need to first look up the ID of the column you’re trying to update, and then tell the API the ID of that column.


Here’s how:


Looking up column ID in the web platform




  1. Click your avatar menu > Developers




  2. Select “monday.labs”:




  3. Activate “Developer mode”




  4. The column ID will be displayed when you click the three-dot menu on a column:




Looking up column ID in the API


You can also make an API query to get the ID of the files column.


Here’s one that returns only the file columns on the board:


query {
boards(ids:4580008543) {
columns (types:file) {
title
id
type
}
}
}


PS: A note on uniqueness


There could be a misunderstanding in the idea of uniqueness, too.


When we say column IDs are unique per board, we mean that all columns on one board will have different IDs.


But multiple boards could have a Files column with the same ID (they probably will).


Hope that helps!


Thank you @dipro , this is very clear ! I feel like this could defenitly be a nice addition to your documentation.


I’m wondering is there any way to satisfy my initial intention, which is to upload a file to the gallery via the api ?

Similar to what happens when clicking on the Add file button on that screen:


When i make the following call with the “wrong” column_id, I can see the file being uploaded in the gallery but the response doesn’t allow me to retrieve the asset id :


Request:


curl --location 'https://api.monday.com/v2/file' \\
--header 'Authorization: xxxxxxxxxxxxxxxxx' \\
--header 'API-version: 2023-10' \\
--form 'query="mutation ($file: File!) {
add_file_to_column (file: $file, item_id: 7689043434, column_id: \\"files\\") {id}}"' \\
--form 'map="{\\"image\\":\\"variables.file\\"}
"' \\
--form 'image=@"/Users/sylvainb/downloads/large-marc.jpg"'

Response:


{"status_code":500,"error_message":"Internal server error","error_code":"INTERNAL_SERVER_ERROR"}%

Thank you 🙂


This suggests that the upload and attachment to the column is actually a 2 step process.


Step 1: upload the file — this is successful, so the file is attached to the item in the gallery.


Step 2: link the file in the gallery to the column — you’ve provided an invalid column id, so this part throws an error.


Perhaps this should happen in a single transaction and roll back if either step fails. Or perhaps it’s good that mdc holds onto the file in the first step. 🤷


Thank you for your intervention @dvdsmpsn but that doesn’t really answer my interrogations 🤷


@dipro @rachelatmonday I may have been too verbose, let me rephrase:



  • Using the api, is it possible to upload a file directly to the gallery without relying on a column ?

  • When following the documentation and using the “files” column_id, it will upload the file to the gallery but return an error. What is wrong here ? The file being uploaded despite the error ? Or the fact that an error is returned ? Both are very confusing for an api consumer’s perspective.


Thanks again.


Hi @sylvainb,


Can you open a support ticket here so our team can take a look at your specific query and try to find out the issue?


Best,

Rachel


Reply