How to fetch subscribers name and userid for particular workitem through REST SDK API
One answer
wi.getSubscriptions() returns a collection. The way you cast indicates you do not see the information. See https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ how to set this up to be able to see the info.
There is no magic here. You iterate the subscribers and resolve the handles. The reverse API is explained here https://rsjazz.wordpress.com/2012/08/02/subscribing-to-a-work-item-using-the-java-api/
Comments
Hi Ralph
I am getting below error
Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy10 incompatible with com.ibm.team.rtc.foundation.api.common.model.IContributor
Below is my code :
public static void Subs(ITeamRepository repo, IWorkItem wi) throws TeamRepositoryException{
IWorkItem workitem = workitemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, null);
for(IContributorHandle subscriber : workitem.getSubscriptions().getContents())
{
IItemManager itemManager = repo.itemManager();
IContributor contributor = (IContributor) itemManager.fetchCompleteItem(subscriber , IItemManager.DEFAULT, null);
contributor.getUserid();
}
}
This is development and not a guessing game. As far as I can tell, you have the following options:
- Follow the links I provided and setup a development environment with the SDK that allows you to see the Java code of the SDK and the API.
- Use the JavaDoc provided with the Plain java client libraries and look up the interfaces
- Run google and search for the countless examples for code here in the forum or elsewhere
You are asking others to do 1,2 or 3 to help you and that is not a great idea. The next question from you is already in the forum.
Comments
Himanshu Vashisth
Nov 16 '19, 10:09 a.m.Below is my code but its showing com.ibm.team.workitem.common.internal.model.Subscriptions incompatible with com.ibm.team.repository.common.IContributorHandle error