It's all about the answers!

Ask a question

Accessing Custom Fields set in RTC for a Project using Rest Services/API

Radhikaa Bhaskaran (612) | asked Mar 24 '14, 8:47 a.m.
 I would like to retrieve the custom fields set for a Project in RTC(version and I am currently trying to use API to do this :

public void getCustomAttributes() {
IProgressMonitor myProgressMonitor = new CustomProgressMonitor(); // Create a progress monitor
final String userId = ""; 
final String password = "";
String repoUri = "";

ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri);
repo.registerLoginHandler(new ILoginHandler2() {
public ILoginInfo2 challenge(ITeamRepository repo) {
return new UsernameAndPasswordLoginInfo(userId, password);
try {
} catch (TeamRepositoryException e) {
// TODO Auto-generated catch block
} finally {

IWorkItemClient workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
try {
IWorkItem workItem = workItemClient.findWorkItemById(18588, IWorkItem.FULL_PROFILE, myProgressMonitor);
List custAttributeHandles = workItem.getCustomAttributes();
for (Iterator iterator = custAttributeHandles.iterator(); iterator.hasNext();) {
   IAttributeHandle iAttributeHandle = (IAttributeHandle);
   IAttribute iAttribute = (IAttribute) repo
       iAttributeHandle, IItemManager.DEFAULT ,myProgressMonitor);;
} catch (TeamRepositoryException e) {

The work item with ID 18588(it has been hard-coded int he above snippet) has a value set for a custom field(say, 'Re-open count' ). I have set the correct userId, password and repoUrl for access.

Issue : 
    The code won't run because there is a NoSuchMethod exception thrown for a class(org/eclipse/core/internal/registry/ExtensionRegistry) whose containing jar is in my Project's build path. I don't see any issue there but I keep getting this exception. Also, hitting the Simple query URL for the Project, exposed by OSLC, retrieves ONLY the built-in fields for the work items such as 'foundIn','description','title',...

Question :
    Is the above code snippet the right way to retrieve custom fields? Or is it possible to do the same using rest services.
Any guidance would be of great help. Thanks in advance.

sam detweiler commented Mar 24 '14, 9:02 a.m.

my sample code here, post 3.

prints out custom as well as builtin  fields. 

I do not know the OSLC/Rest  answer personally, but I think one has to get the workitem 'Shapes' (which gives u the ids of the other attributes) 

One answer

permanent link
Radhikaa Bhaskaran (612) | answered Mar 25 '14, 3:14 a.m.
Hi Sam.

Thanks very much for your prompt response. I was able to obtain all custom attributes without any hassles. You are a star!

Your answer

Register or 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.