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

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

book

Article ID: 57545

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

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. 

1. To set workspace on query request:

String workspaceRef = "/workspace/<WORKSPACE_OID>";
QueryRequest storyRequest = new QueryRequest("HierarchicalRequirement");
storyRequest.setWorkspace(workspaceRef);


2. To set project on query request:

String projectRef = "/project/<PROJECT_OID>";
QueryRequest defectRequest = new QueryRequest("Defect");
defectRequest.setProject(projectRef);
defectRequest.setScopedDown(true);
defectRequest.setScopedUp(false);


3. To set project on create request:

String projectRef = "/project/<PROJECT_OID>";
JsonObject newStory = new JsonObject();
newStory.addProperty("Project", projectRef);