Deleting attachment doesn't work

Infos:

  • Used Zammad version: 6.0.0-1693485274.bcb37f95.buster
  • Used Zammad installation type: installed via apt as package
  • Operating system: Debian GNU/Linux 10 (buster)
  • Browser + version: Using CURL

Expected behavior:

When I run command from command line: curl -k -H "Authorization: Token token=redacted" https://redacted.com/api/v1/attachments/12345 > attachment.xlsx then the attachment is downloaded and I can open it in native application.
When I then run command curl -k -X DELETE -H "Authorization: Token token=redacted" https://redacted.com/api/v1/attachments/12345 then I expect the attachment to be deleted from Zammad.

Actual behavior:

When I run command from command line: curl -k -H "Authorization: Token token=redacted" https://redacted.com/api/v1/attachments/12345 > attachment.xlsx then the attachment is downloaded and I can open it in native application.
When I then run command curl -k -X DELETE -H "Authorization: Token token=redacted" https://redacted.com/api/v1/attachments/12345 then result is {“error”:“ActiveRecord::RecordNotFound”,“error_human”:“ActiveRecord::RecordNotFound”}

Steps to reproduce the behavior:

  1. Create a ticket
  2. Attach a file
  3. Query the ticket to make sure I have correct ID with command: curl -k -H “Authorization: Token token=redacted” https://redacted.com/api/v1/tickets/123
  4. Query the articles of that ticket with command: curl -k -H “Authorization: Token token=redacted” https://redacted.com/api/v1/ticket_articles/by_ticket/123
  5. Format the JSON and find attachment ID that I want to delete
  6. Run command: curl -k -X DELETE -H “Authorization: Token token=redacted” https://redacted/api/v1/attachments/12345

I’ll just add that this is what the article looked like:
{
“id”: 55267,
“ticket_id”: 6384,
“type_id”: 11,
“sender_id”: 2,
“from”: “redacted”,
“to”: “”,
“cc”: “”,
“subject”: “”,
“reply_to”: null,
“message_id”: null,
“message_id_md5”: null,
“in_reply_to”: “”,
“content_type”: “text/html”,
“references”: null,
“body”: “redacted”,
“internal”: false,
“preferences”: {},
“updated_by_id”: 219,
“created_by_id”: 219,
“origin_by_id”: 219,
“created_at”: “2023-09-14T22:24:48.570Z”,
“updated_at”: “2023-09-14T22:24:48.570Z”,
“attachments”: [
{
“id”: 86267,
“store_file_id”: 72157,
“filename”: “redacted”,
“size”: “51123”,
“preferences”: {
“Content-Type”: “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”
}
}
],
“created_by”: “redacted”,
“updated_by”: “redacted”,
“type”: “web”,
“sender”: “Customer”,
“origin_by”: “redacted”
},

And I have used the ID 86267.

So my command to remove the attachment was: curl -k -X DELETE -H “Authorization: Token token=redacted” https://redacted.com/api/v1/attachments/86267

Any ideas why it did not work? Is there something else I can do or check?

As far as I know, deleting individual attachments from tickets isn’t supported. So far the only official solution has been to delete the entire ticket, which would also remove the attachment (if there are no other tickets referencing the same file).

1 Like