Java Rally REST API:如何创建新的测试用例

Java Rally REST API: How to create new test case

我已经能够通过 Rally API 成功创建测试结果,但现在我想创建一个测试用例,如果 Rally 中还没有的话。

我从 Rally 收到“对象 ID 为空”的错误,这意味着 Rally 认为我正在更新测试用例,即使我正在尝试创建一个测试用例。

有没有人试过创建测试用例 Rally API,或者有没有人看到我需要修复什么? 谢谢!

//Method to build the JSON and create the new test CASE in Rally
    public static void createNewTestCase(String currentMethodName) 
    throws URISyntaxException, IOException{
        Configuration conf = new Configuration();
        RallyRestApi restApi = new RallyRestApi(new URI(
        "https://rally1.rallydev.com"),
        {authentication code});
        restApi.setApplicationName("Test Case");             
         try {
                //Create test case
                JsonObject newTestCase = new JsonObject();
                newTestCase.addProperty("Name", currentMethodName);
                newTestCase.addProperty("Description", "Created by Rally");
                newTestCase.addProperty("Project", "Project1"));
                newTestCase.addProperty("Type", "Functional");
                newTestCase.addProperty("Method", "Automated");
                newTestCase.addProperty("DefectStatus", "NONE");
            CreateRequest createRequest = new CreateRequest("testcase",
                newTestCase);
            CreateResponse createResponse = restApi.create(createRequest);
                if (createResponse.wasSuccessful()){
                System.out.println("Test case created successfully");
                }
                else {
                System.out.println("The test case could not be created");
                String[] createErrors;
                createErrors = createResponse.getErrors();
                System.out.println("Error occurred creating Test Case: ");
                for (int i=0; i<createErrors.length;i++) {
                   System.out.println(createErrors[i]);
               }
                }

         }catch (Exception e){
                e.printStackTrace();
         }
         finally {
                restApi.close();
         }
   }

我猜问题出在设置项目上。 Rally 中的对象关系始终表示为引用:/type/objectid.

newTestCase.addProperty("Project", "/project/12345");