2015-03-31 67 views
0

我正尝试在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 = "[email protected]"; 
    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" 

请帮助。新的集会。在此先感谢

回答

2

当设置指向完整对象的项目,迭代,发布,WorkProduduct,父等参考字段使用引用,而不是名称。

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

替换:

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

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

为了您可以由它的名字查询在WS API找到一个项目的对象ID,或看拉力赛的一个网页的URL中地址栏,而在该项目中,例如Backlog页面的URL:https://rally1.rallydev.com/#/123456/backlog

如果存在附加到ObjectID字符串的du,例如, 123456d,不要将其包含在字符串中。在URL中,它表明您目前是在向上还是向下。