How set which Workspace/Project you want to work in when you first login using the Java Rest API

Document ID : KB000057545
Last Modified Date : 14/02/2018
Show Technical Document Details

Issue

A user observed that by default requests are scoped to the default Workspace/Project of the user whose credentials are used when running a java application based on Rally Rest Toolkit for Java.

Resolution

Below are examples of setting an explicit scope of the request with Rally Rest Toolkit for Java. Replace placeholders(e.g. 12345) with valid ObjectIDs of workspace or project in your Rally subscription. To find out ObjectIDs of workspaces and projects without admin rights, login to Rally to the intended Workspace and Project and see this Knowledge Base article for details.

1. To set workspace on query request:
?
String workspaceRef = "/workspace/12345";
QueryRequest storyRequest = new QueryRequest("HierarchicalRequirement");
storyRequest.setWorkspace(workspaceRef);

2. To set project on query request:
?
String projectRef = "/project/3456";
QueryRequest defectRequest = new QueryRequest("Defect");
defectRequest.setProject(projectRef);
defectRequest.setScopedDown(true);
defectRequest.setScopedUp(false);

3. To set project on create request:
?
String projectRef = "/project/3456";
JsonObject newStory = new JsonObject();
newStory.addProperty("Project", projectRef);


?