Service Desk Practitioners Forum
cancel

Add Attachement to Servicecall through api

Highlighted
Sam K
Valued Contributor.

Add Attachement to Servicecall through api

Hi,

Can anyone tell me how to add attachment to Servicecall through api. I tried with following code but it not find the file to be attached using searchOnFilename(). I don't know where it is searching the file. Here is the code.

IAttachment attach = servicecall[0].getAttachment();
IAttachedItemHome attachHome = session.getAttachedItemHome();
IAttachedItemWhere attachWhere = attachHome.createAttachedItemWhere();
IAttachedItem[] attachItem = attachHome.searchOnFilename("E:\\workspace\\Sample\\HPSD_test.txt");

Thanks,
Sam
6 REPLIES
Vasily Kamenev
Acclaimed Contributor.

Re: Add Attachement to Servicecall through api

HI
The APi functions only for adding scortcuts to Attachment on SC or other module. You need also transfer attachment to ftp server: send or recive by ftp protocol. I'm for it use own ftp client on java, becuse not found description on HP ftpClient.

Regards,
Vasily
Sam K
Valued Contributor.

Re: Add Attachement to Servicecall through api

Hi,

Thanks for your reply. Using ftp we can upload or download files. but i don't know how to do it for servicecall. That is how to combine ftp to HPSD web-api?

Thanks,
Sam
Vasily Kamenev
Acclaimed Contributor.

Re: Add Attachement to Servicecall through api

Hi
look on Example9.java you just need add ftp client in source.

Vasily
Sam K
Valued Contributor.

Re: Add Attachement to Servicecall through api

Hi,

Where can i find Example9.java?

Regards,
Sam
Mark O'Loughlin
Acclaimed Contributor.

Re: Add Attachement to Servicecall through api

Hi Sam,

Have a look in the \api\examples folder of any of the later service packs (could also be in older oner) and you will find the example
Sam K
Valued Contributor.

Re: Add Attachement to Servicecall through api

Hi,

Thanks for reply. I have found the example. Do i have to upload file to ftp server and then have to set the file name using setFilename()?. Without using ftp i tried to attach file which exist in another servicecall it throws following exception:
Error when put file ServiceCall Exception Code to attachment server: java.io.FileNotFoundException: ServiceCall Exception Code (The system cannot find the file specified)