2
我正在嘗試使用Rally Java REST API - https://github.com/RallyTools/RallyRestToolkitForJava。我如何定義工作區和項目以便在哪裏創建新的用戶故事?它似乎只是使用我的配置文件中定義的「默認」工作區。我能夠創建用戶故事,除了我想要的位置以外,沒有其他問題。任何幫助,將不勝感激。如何使用Rally Java工具包創建故事時指定項目?
我正在嘗試使用Rally Java REST API - https://github.com/RallyTools/RallyRestToolkitForJava。我如何定義工作區和項目以便在哪裏創建新的用戶故事?它似乎只是使用我的配置文件中定義的「默認」工作區。我能夠創建用戶故事,除了我想要的位置以外,沒有其他問題。任何幫助,將不勝感激。如何使用Rally Java工具包創建故事時指定項目?
你可以設置一個項目引用:
String projectRef = "/project/222";
,然後使用方法addProperty:
newStory.addProperty("Project", projectRef);
這是一個完整的例子:
public class CreateStory {
public static void main(String[] args) throws URISyntaxException, IOException {
String host = "https://rally1.rallydev.com";
String username = "[email protected]";
String password = "secret";
String wsapiVersion = "v2.0";
String projectRef = "/project/2222";
String workspaceRef = "/workspace/11111";
String applicationName = "RestExample_createStory";
RallyRestApi restApi = new RallyRestApi(
new URI(host),
username,
password);
restApi.setWsapiVersion(wsapiVersion);
restApi.setApplicationName(applicationName);
try {
for (int i=0; i<3; i++) {
//Add a story
System.out.println("Creating a story...");
JsonObject newStory = new JsonObject();
newStory.addProperty("Name", "my story");
newStory.addProperty("Project", projectRef);
CreateRequest createRequest = new CreateRequest("hierarchicalrequirement", newStory);
CreateResponse createResponse = restApi.create(createRequest);
if (createResponse.wasSuccessful()) {
System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));
//Read story
String ref = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
System.out.println(String.format("\nReading Story %s...", ref));
GetRequest getRequest = new GetRequest(ref);
} else {
String[] createErrors;
createErrors = createResponse.getErrors();
System.out.println("Error occurred creating story: ");
for (int j=0; i<createErrors.length;j++) {
System.out.println(createErrors[j]);
}
}
}
} finally {
//Release all resources
restApi.close();
}
}
}