ray500
ray500

Reputation: 163

Unable to query a different workspace

I was trying to follow this post to query a testcase in a workspace("/workspace/6749437088") that is not the default workspace but the query is not returning that testcase and in fact, not returning anything. Below is the code I am using. If I do a query with 'not equal' the test cases, I notice that it is returning test cases in the user's default workspace. I am using C# and using Rally Rest API Runtime v4.0.30319 and ver 1.0.15.0. Any suggestions? Thanks.

Inserting test case result using Java Rally Rest API failing when workspace is different from default set on account

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;

Upvotes: 1

Views: 199

Answers (2)

ray500
ray500

Reputation: 163

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.

Upvotes: 1

Kyle Morse
Kyle Morse

Reputation: 8410

The code above seems like it should work. This may be a defect- I'll look into that. In the meantime if you are just trying to read a specific object from Rally by Object ID you should be able to do so like this:

restApi.GetByReference('/testcase/12345', 
    'Results, 'Verdict', 'Duration' //fetch fields);

Upvotes: 0

Related Questions