How to remove / delete file from item via API

Hello,

I can upload file from API with GraphQL (“mutation add_file”); however, I cannot update or remove file from item. Is there any endpoint to update/delete file from related column of board item.

Thanks.

Turan

Hello Turan,

I believe the way to do this is by updating the column value for your particular file column using the {“clear_all”: true} value.

Please note that this will remove all files from the item’s column value, as the feature to remove individual items is not available. I have provided a link below to where the documentation highlights the available functionality. I believe that you may find your solution down at the very bottom with Removing Column Values.

Please let us know if this works for you.

Thank you and happy coding!

Andrew

1 Like

Hey @tgurler :wave:

I agree with @andrew.shatz’s great response here! You will not be able to remove a single file from the File column at this time, and you’d need to resort to removing all files at once as of right now.

Let us know if this would work for you - otherwise, we could change this topic into a feature request :slight_smile:

-Alex

Thanks for the answer, I tried this query but it did not make any update; did I miss anything?

mutation { change_simple_column_value (board_id: 1803949189, item_id: 1803949221, column_id: "files", clear_all: "true") { id } }

@AlexSavchuk the feature that removes all files covers our requirement but if there is a feature to remove specific file by asset id or something, it will be useful; because users can upload their own files; but if we can remove only files that are uploaded by API will be useful.

Thanks.

Btw, when I use this:

query: mutation { change_column_value (board_id: 1803949189, item_id: 1803949221, column_id: "files", value: "", clear_all: "true") { id } }

I got this response:
response: {"error_message":"Internal server error","status_code":500}

Hello Turan,

You are getting that error because you need to set the value in your request as the serialized json of the {“clear_all”: true} object. A correction is shown below.

mutation { change_column_value (item_id: 1803949221, column_id:"files", board_id: 1803949189, value:"{\\"clear_all\\": true}") { id } }

Please let us know if this works for you.

Thanks!

Amazing as always, @andrew.shatz !

@tgurler, please let us know if you are still having issues with this, or if Andrew’s suggestion helped :slight_smile:

-Alex

It works now great. Thank you all :slight_smile:

2 Likes

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