Service Desk Practitioners Forum
cancel

Problem with Attachments through WebAPI

Highlighted
Colleen Talbert
Super Contributor.

Problem with Attachments through WebAPI

We are using a Java application, using the WebAPI JAR file. This app needs to attach a file to the service call. Everything works fine, and the file attaches. You just can’t see it when you open up the service call in service desk. If you attach another unrelated file, you suddenly see BOTH files. Also, if there was already a file attached, and WebAPI attaches a 2nd file, everything works fine! Its as if WebAPI by itself can’t cause the service call to open the attachment area at the bottom. I am using the following code to do the attachment. Which basically came from one of the examples.

Any suggestions?

public void addAttachment(int serviceCallID, String filename)
{
IServicecallHome serviceCallHome = session.getServicecallHome();
IServicecall serviceCall = serviceCallHome.openServicecall(serviceCallID);

// Build a new attached item
IAttachedItemHome aHome = session.getAttachedItemHome();
IAttachedItem nItem = aHome.openNewAttachedItem();
File f = new File(filename);
nItem.setFilename(filename);
nItem.setBaseName(f.getName());
// Make the new attached item aware of its parent entity type. This
// attribute is not automatically set when the new attached item is
// added to a parent.
IEntityInfoHome entInfHome = session.getEntityInfoHome();
IEntityInfo entInfo = entInfHome.openEntityInfo(serviceCall.getItemType());
nItem.setParentEntityType(entInfo);

// Add the new attached item, it is automatically saved
serviceCall.getAttachment().addAttachedItem(nItem);

}

Thank!
Colleen
1 REPLY
Vasily Kamenev
Acclaimed Contributor.

Re: Problem with Attachments through WebAPI

Hi
Use code locale on application server, then will working. This is a bag of web-api, I'm already wrote about in this forum http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1287748.

Vasily