Welcome to the Jazz Community Forum
Add attachments to work item

Hi,
I'm trying to add attachments to the existing work item. Here is my code:
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
ItemProfile<IWorkItem> profile = ItemProfile.computeProfile(workitem);
wcm.connect(workItemHandle, profile, monitor);
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItemHandle);
IWorkItemReferences refs = wc.getReferences();
** It failed when get references with exception
"Feature not contained in access profile WorkItem"
Am I doing it right?
Then I tried to get the references with the following code and it ran through ok:
IWorkItemHandle handle = (IWorkItemHandle)wc.getWorkItem().getItemHandle();
IWorkItemReferences refs = workItemClient.resolveWorkItemReferences(handle, monitor);
After I got the references, I do (file is File object):
IReference ref = IReferenceFactory.INSTANCE.createReferenceFromURI(file.toURI(), file.getAbsolutePath());
if (ref != null) {
refs.add(WorkItemEndPoints.ATTACHMENT, ref);
}
wcm.save(new WorkItemWorkingCopy[]{wc}, monitor);
After save, I try to get the list of references from the work item to see if the work item save correctly. But the list of references is empty.
Any idea? Anything wrong with my code?
Thanks alot for the help, really appreciated.
Thanks!!
I'm trying to add attachments to the existing work item. Here is my code:
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
ItemProfile<IWorkItem> profile = ItemProfile.computeProfile(workitem);
wcm.connect(workItemHandle, profile, monitor);
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItemHandle);
IWorkItemReferences refs = wc.getReferences();
** It failed when get references with exception
"Feature not contained in access profile WorkItem"
Am I doing it right?
Then I tried to get the references with the following code and it ran through ok:
IWorkItemHandle handle = (IWorkItemHandle)wc.getWorkItem().getItemHandle();
IWorkItemReferences refs = workItemClient.resolveWorkItemReferences(handle, monitor);
After I got the references, I do (file is File object):
IReference ref = IReferenceFactory.INSTANCE.createReferenceFromURI(file.toURI(), file.getAbsolutePath());
if (ref != null) {
refs.add(WorkItemEndPoints.ATTACHMENT, ref);
}
wcm.save(new WorkItemWorkingCopy[]{wc}, monitor);
After save, I try to get the list of references from the work item to see if the work item save correctly. But the list of references is empty.
Any idea? Anything wrong with my code?
Thanks alot for the help, really appreciated.
Thanks!!