1

我试图按照这篇文章在不是默认工作区的工作区(“/workspace/6749437088”)中查询一个测试用例,但查询没有返回该测试用例,实际上也没有返回任何东西。下面是我正在使用的代码。如果我使用“不等于”测试用例进行查询,我注意到它正在返回用户默认工作区中的测试用例。我正在使用 C# 并使用 Rally Rest API Runtime v4.0.30319 和 1.0.15.0 版。有什么建议么?谢谢。

当工作区与帐户上的默认设置不同时,使用 Java Rally Rest API 插入测试用例结果失败

private string  GetRallyObj_Ref(string ObjFormttedId)
   {
       string tcref = string.Empty;
       try
       {
           string reqType = _Helper.GetRallyRequestType(ObjFormttedId.Substring(0, 2).ToLower());
           Request request = new Request(reqType);
           request.Workspace = "/workspace/6749437088";

           request.Fetch = new List<string>()
           {
               //Here other fields can be retrieved
               "Workspace",
               "Name",
               "FormattedID",
               "ObjectID"
           };
           //request.Project = null;
           string test = request.Workspace;

           request.Query = new Query("FormattedID", Query.Operator.Equals, ObjFormttedId);

           QueryResult qr = _RallyApi.Query(request);

           string objectid= string.Empty;
           foreach (var rslt in qr.Results)
           {
               objectid = rslt.ObjectID.ToString();
               break;
           }
           tcref = "/"+reqType+"/" + objectid;
       }
       catch (Exception ex)
       {
           throw ex;
       }
       return tcref;
4

2 回答 2

1

Sorry, I found out the issue. I was feeding the code a project ref#, not a workspace ref #. I found out the correct workspace by using pieces of the code in the answer part of this post: Failed when query users in workspace via Rally Rest .net api by querying the workspace refs of the username I am using and there I found out the correct workspace ref. Thanks, Kyle anyway.

于 2013-07-03T21:06:38.377 回答
0

上面的代码似乎应该可以工作。这可能是一个缺陷——我会调查的。同时,如果您只是尝试通过对象 ID 从 Rally 中读取特定对象,您应该可以这样做:

restApi.GetByReference('/testcase/12345', 
    'Results, 'Verdict', 'Duration' //fetch fields);
于 2013-07-02T14:40:51.100 回答