sid
sid

Reputation: 925

Rally: Get user _ref from RallyRestApi object created using ApiKey

I created a connection to rally using the ApiKey constructor.

Question is how do i find out the User "_ref" associated with this User ApiKey ?

rallyRestApi= new RallyRestApi(new URI(host), "myApiKey");

I tried following 2 test runs:

  1. doing a blank query (i.e. without any setQueryFilter) on User object; it returns me all the users.

    QueryRequest userRequest = new QueryRequest("User"); QueryResponse userQueryResponse = connection.query(userRequest); JsonArray userQueryResults = userQueryResponse.getResults();

  2. Getting owner from Workspace object >> This returns me the owner of the Workspace

Upvotes: 0

Views: 230

Answers (1)

nickm
nickm

Reputation: 5966

You may get a current user:

GetRequest getRequest = new GetRequest("/user");
GetResponse getResponse = restApi.get(getRequest);
JsonObject currentUser = getResponse.getObject();
String currentUserName = currentUser.get("_refObjectName").getAsString();
String currentUserRef = currentUser.get("_ref").getAsString();
System.out.println("current user: " + currentUserName + currentUserRef);

I tested it with latest Rally API toolkit for Java.

Upvotes: 1

Related Questions