Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to fetch subscribers name and userid for particular workitem through REST SDK API

 How to fetch subscribers name and userid for particular workitem through REST SDK API

0 votes

Comments

 Below is my code but its showing com.ibm.team.workitem.common.internal.model.Subscriptions incompatible with com.ibm.team.repository.common.IContributorHandle error 


Please help for the same.

IContributorHandle conHandle = (IContributorHandle) wi.getSubscriptions();



//ITeamRepository repo1 = (ITeamRepository) conHandle.getOrigin();



IContributor contrib = (IContributor) repo.itemManager().fetchCompleteItem(conHandle, IItemManager.DEFAULT, null);




System.out.println("Owner" +contrib.getUserId());

 



One answer

Permanent link
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/

0 votes

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:
  1. 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.
  2. Use the JavaDoc provided with the Plain java client libraries and look up the interfaces
  3. 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.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Nov 16 '19, 9:39 a.m.

Question was seen: 667 times

Last updated: Nov 18 '19, 1:47 a.m.

Confirmation Cancel Confirm