创建故事时出错:“无法解析对象引用”,Rally

时间:2015-03-31 08:50:21

标签: rally

我正试图通过java在集会中创建用户故事。我没有得到响应,它抛出“无法解析对象引用”。

关于我的集会的简要说明:假设我有项目名称“人物”,它的子项为A,B,C,D。我必须用C创建我的用户故事。这个前景中我的下列代码是否正确?有人可以帮忙吗?

package samplerally;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.request.GetRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.util.Ref;

public class CreateStory {
public static void main(String[] args) throws URISyntaxException,IOException {

     String host = "https://rally1.rallydev.com";
     String username = "name@comp.com";
     String password = "password";
     String wsapiVersion = "v2.0";
     String applicationName = "C";

 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", "Characters");

            CreateRequest createRequest = new CreateRequest("hierarchicalrequirement", newStory);
            CreateResponse createResponse = restApi.create(createRequest);
            System.out.println("Response ::: "+createResponse.wasSuccessful());
            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; j < createErrors.length; j++) {
                    System.out.println(createErrors[j]);
                }
            }
        }
    } finally {
        // Release all resources
        restApi.close();
    }
}
}

我收到的错误是:

Creating a story...
Response ::: false
Error occurred creating story: 
Could not read: Cannot parse object reference from "BSS HWSE Team Columbia"
Creating a story...
Response ::: false
Error occurred creating story: 
Could not read: Cannot parse object reference from "BSS HWSE Team Columbia"
Creating a story...
Response ::: false
Error occurred creating story: 
Could not read: Cannot parse object reference from "BSS HWSE Team Columbia"
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:\Program Files\HP\Unified Functional Testing\bin\java_shared\classes";"C:\Program Files\HP\Unified Functional Testing\bin\java_shared\classes\jasmine.jar"

请帮忙。反弹的新手。提前致谢

1 个答案:

答案 0 :(得分:2)

当设置指向完整对象的参考字段(如Project,Iteration,Release,WorkProduduct,Parent等)时,使用引用,而不是名称。

找出项目“C”的唯一ObjectID,例如123456。

替换:

newStory.addProperty("Project", "Characters");

newStory.addProperty("Project", "/project/123456");

要查找项目的ObjectID,您可以在WS API中按名称查询,或查看地址栏中其中一个Rally页面的URL,而在该项目中,例如积压页面的网址:https://rally1.rallydev.com/#/123456/backlog

如果ObjectID字符串附加了du,例如123456d,不要将其包含在字符串中。在URL中,它表示您当前是否正在确定范围。