I have a function which uploads the screenshot of a web-page to an incident as an attachment. The name of the attachment is a unique ID which will always be the same for one web-page. The problem is that when the function runs again for a same webpage, a new file is added to the attachments with the same name instead of overwriting the previous already existing.
What I want to do is that my function should first check whether a file of similar name already exists in the attachments, if yes, then it should delete it before uploading it again. But so far, I haven't found a way to check if an attachment already exists, by name, and then delete it.
Can someone point me towards the REST API Endpoints to achieve the above or if there is some other workaround for achieve my objective?
Thanks!
------------------------------
Umair Ahmed
------------------------------