It's all about the answers!

Ask a question

RTC Java Client Library

evrim dutagaci (112) | asked May 20 '16, 10:07 a.m.
I am trying to access RTC from my java application. The api documents are really not good enough to develop a proper code and there is no javadoc either.  So I really need help out here to go further.
I managed to connect RTC and get some basic information about a work item but what I need is a bit more than that. I need the information that we can access with RTC UI on build request page, like Deployment description, References ext. Could some one please help me how I can get that information.

3 answers

permanent link
Arun K Sriramaiah (3.2k12254) | answered May 20 '16, 10:43 a.m.
Hi Evrim,

If you are not already refereed the below link, I would request you to refer.

Note: Refer discussion also from the links.


evrim dutagaci commented May 20 '16, 11:04 a.m. | edited May 22 '16, 9:42 p.m.

Hi Arun,
I am using the below method and getting a null pointer exception when I try to get itemId from build definition, although my work item id is correct.

public static void getBuildRequest(ITeamRepository repo) throws TeamRepositoryException {
        ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);
        / The build definition is easy to get once you know the build ID /
        IBuildDefinition definition = buildClient.getBuildDefinition("313491", null);
        System.out.println("definition.getItemId(): "+ definition.getItemId());
        IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT;
        IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel);

        / Build up a query filter predicate that accepts a build definition as input to the query and checks for
           any non-personal builds that have a completed state.
        IPredicate predicate = (buildResultQueryModel.buildDefinition()._eq(query.newItemHandleArg()))._and(


        / Order by build start time in descending order /

        / Query for items using the build definition's item ID as the argument. /
        / Use a smaller page size if possible depending on what is queried. /
        IItemQueryPage queryPage = buildClient.queryItems(query, new Object[] { definition.getItemId() },
                    IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, null);

        / Iterate through the results of this page /

        while (queryPage.hasNext()) {
            queryPage = (IItemQueryPage) buildClient.fetchPage(queryPage.getToken(), queryPage.getNextStartPosition(), 1, null);
            / Iterate through each subsequent page. Break out of the loop if finished early. /

and here is the code that let me connect to repo

String repoUri = "";

        try {
            // Login to the repository using the provided credentials
            if(TeamPlatform.getTeamRepositoryService() != null) {
            ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri);
            repo.registerLoginHandler(new ILoginHandler2() {
                public ILoginInfo2 challenge(ITeamRepository repo) {
                    String userId = "jhhjkll3"; // Retrieve the userId in a secure way
                    String password = "kkk"; // Retrieve the password in a secure way
                    return new UsernameAndPasswordLoginInfo(userId, password);

permanent link
Ralph Schoon (60.5k33643) | answered May 23 '16, 3:15 a.m.
Follow and properly set up your environment for debugging. Note the SDK comes with comments. shows some built API.

Finally, the, IProgressMonitor) wants the Build Definition ID and not the build ID.

     * Retrieves the build definition with the given id.
     * @param buildDefinitionId
     *            The build definition to retrieve.
     * @param progressMonitor
     *            The progress monitor to track progress on or <code>null</code>
     *            if progress monitoring is not desired.
     * @return The build definition, or <code>null</code> if no build
     *         definition with the given id is found.
     * @throws IllegalArgumentException
     *             If the <code>buildDefinitionId</code> is <code>null</code>.
     * @throws TeamRepositoryException
     *             If an error occurs while accessing the repository.
    public IBuildDefinition getBuildDefinition(String buildDefinitionId, IProgressMonitor progressMonitor)
            throws TeamRepositoryException, IllegalArgumentException;

permanent link
evrim dutagaci (112) | answered May 24 '16, 8:22 a.m.
edited May 24 '16, 8:23 a.m.
Hi Arun,
Thanks for your response, unfortunately I am still struggling to get the information that I need with RTC library. Here is what I really need to get. Could you please help me how can I get that information by using RTC java API. In RTC, we have a custom part in work item which we called Build/Deployment, you can see how it looks like from the screenshot below. Could you please tell me by using which classes I can get the data inside that part?

Thanks & REgards

Your answer

Register or to post your answer.