Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

How to DELETE Attachments using the Web API ?

Highlighted
Marty Brown_1
Regular Collector

How to DELETE Attachments using the Web API ?

Hi All,

HPSD 4.5 SP21 here...

Trying to figure out how to DELETE Attachments from a Service Call ticket using Web API Java code.

Example9.Java ably shows how to *Add* a new attachment, but I can't figure out how to *delete* an already attached one.

Our situation is that we have inbound email turned on, which converts incoming emails into Service Call tickets, and converts embedded images and email attachments into HPSD Attachments.

This works great, except that we end up with our corporate logo (which is a default component of everybody's Email Signature file) being saved as an extra attachment to each Service Call that gets created.

I'm interested in using a Java program to rip through the attachments for a given Service Call ID number, and Delete any attachments that are the exact Size of our embedded logo file.

Would be grateful for ideas, and/or Sample Code would be ideal!

Happy Holidays!

~Marty
2 REPLIES
Vasily Kamenev
Honored Contributor

Re: How to DELETE Attachments using the Web API ?

Hi
Seem is like that: item.getAttachment().getAttachedItems()[0].delete();

Vasily
Marty Brown_1
Regular Collector

Re: How to DELETE Attachments using the Web API ?

Thanks Vasily, but...

You are right that the command you provided will Un-relate the attachment from the Service Call, but it won't actually delete the attaced file from the FTP location.

Also, I'm looking for a way to interrogate the actual attachment file at the FTP location, so that I can determine its size, so that I can determine if I want to Delete/Un-Relate it or not...

I've found some Java Code attached to Thread ID 1056387 that looks promising to be able to interrogate the attachment FTP location, so I'm going to dig into that.

Thanks and Happy Holidays!

~Marty
//Add this to "OnDomLoad" event