我正在尝试使用 Java 中的 Rally REST API 创建缺陷。
我插入缺陷的代码如下所示:
JsonObject newDefect = new JsonObject();
newDefect.addProperty("Workspace", workspaceRef);
newDefect.addProperty("Project", projectRef);
newDefect.addProperty("Name", d.name);
newDefect.addProperty("Description", d.description);
newDefect.addProperty("Notes", d.notes);
newDefect.addProperty("Owner", getUserReference(restApi, d.owner));
System.out.println("Creating defect: " + d.qcid + " - " + d.name);
CreateRequest createRequest = new CreateRequest("defect", newDefect);
CreateResponse createResponse = restApi.create(createRequest);
getUserReference 实现如下:
private String getUserReference(RallyRestApi restApi, String name) throws Exception
{
// Read User
QueryRequest userRequest = new QueryRequest("User");
userRequest.setFetch(new Fetch("UserName", "Subscription", "DisplayName"));
userRequest.setQueryFilter(new QueryFilter("UserName", "=", name));
QueryResponse userQueryResponse = restApi.query(userRequest);
JsonArray userQueryResults = userQueryResponse.getResults();
JsonElement userQueryElement = userQueryResults.get(0);
JsonObject userQueryObject = userQueryElement.getAsJsonObject();
String userRef = userQueryObject.get("_ref").toString();
return userRef;
}
问题:我收到用户错误“无法解析对象引用”。当我使用实际名称 (user@domain.com) 或上面描述的用户参考时,我会得到它。
我得到的当前错误是:无法解析来自“” https://rally1.rallydev.com/slm/webservice/v2.0/user/14659049875 “”的对象引用
我究竟做错了什么?
谢谢阿萨夫