Attachments vs Discussion with Attachments

Am using below Smartsheet API to get all the attachments. It brings the attachments from attachments and attachment available under Discussion. No problem in that.

smartsheetclient.Attachments.get_attachment(sheet_id, attachment_id)

While deleting the attachments using the below API. Here the problem is attachments section delete works fine and attachment under discussion give permission error. Am using admin user token to get and delete this file.

smartsheetclient.Attachments.delete_attachment(sheet_id, attachment_id)

Am not able to get attachment under discussion objects. Below is the reference and used the same code. However there is no attachments under discussions -> Array objects.

https://smartsheet.redoc.ly/tag/discussionsObjects

Answers

  • Hi @karthick

    Were you able to figure this out? I was able to delete the attachment by getting the attachment id using GET attachment, and then using that ID in the Delete Attachment.

    Here's how I did it in Postman:

    Then

    I did get a permission error when I was using an Admin access token trying to delete someone else's attachment, so I would suggest ensuring that your token is the appropriate one to make a deletion. Try the same action but ensure you're the one who uploaded the attachment.

    Another option, if this is uploaded by someone else, would be to delete the entire discussion which would remove the image at the same time.

    Cheers,

    Genevieve

    Join us at Smartsheet ENGAGE 2024 🎉
    October 8 - 10, Seattle, WA | Register now

  • karthick
    karthick ✭✭✭
    edited 04/10/24

    Thanks @Genevieve P. for your response. Moreover I found the similar findings. We cannot delete attachment uploaded by others. If we delete the entire discussion then that discussion contains attachment also will get deleted.

    Thanks for you reply and spending valuable time on this.

  • Lee Joramo
    Lee Joramo ✭✭✭✭✭✭
    edited 04/12/24

    If you are accessing the API via an Admin account, you should be able to use the "Assume User" option on your API requests to impersonate the user who created the Discussion attachment.

    I have not done this exact usage on Discussion Attachments, but. I have used Assume User to create discussion messages on behalf of a user.

    https://smartsheet.redoc.ly/#section/API-Basics/Assume-User