Rally Software

Expand all | Collapse all

Example C# REST API code to upload a Test Case Result

Jump to Best Answer
  • 1.  Example C# REST API code to upload a Test Case Result

    Posted 03-21-2017 03:05 PM

    Where can I find example C# REST API code to upload a Test Case Result?



  • 2.  Re: Example C# REST API code to upload a Test Case Result

    Posted 03-21-2017 04:30 PM

    Hi williereed,

     

    Have you taken a look at the github repo? GitHub - RallyTools/RallyRestToolkitFor.NET: A .Net 4.0 Toolkit for Accessing Rally's Webservice API 

     

    there is a link at the bottom to some documentation which includes a create example - Rally.RestApi Namespace 



  • 3.  Re: Example C# REST API code to upload a Test Case Result

    Posted 03-21-2017 05:22 PM

    Thank you, yes I'd seen the Defect example, optimistically hoping a Test Case Result example exists.



  • 4.  Re: Example C# REST API code to upload a Test Case Result

    Posted 03-21-2017 06:54 PM

    Hi Willie,

     

    I am not much of a .net programmer, but I do have a Java example. You might be able to deduce how to do it from that?

                System.out.println("Creating Test Case Result...");

                JsonObject newTestCaseResult = new JsonObject();

                newTestCaseResult.addProperty("TestCase","/testcase/99999999999");

                newTestCaseResult.addProperty("Workspace","999999999999");

                newTestCaseResult.addProperty("Project","999999999999");

                newTestCaseResult.addProperty("Build","9");

                newTestCaseResult.addProperty("Verdict", "Pass");

                newTestCaseResult.addProperty("Date","2016-05-09T16:14:00");

                newTestCaseResult.addProperty("Notes", "Blah");

                newTestCaseResult.addProperty("Tester", "/user/9999999999");

                CreateRequest createRequest = new CreateRequest("testcaseresult", newTestCaseResult);

                CreateResponse createResponse = restApi.create(createRequest);

     

    You can use the online interactive WSAPI document to determine which attributes are required for TestCaseResult.

    https://rally1.rallydev.com/slm/doc/webservice/ 

     

    Let me know if that helps or not.

     

    Thanks,

    Sean Davis



  • 5.  Re: Example C# REST API code to upload a Test Case Result
    Best Answer

    Posted 03-22-2017 12:25 PM

    From looking at the .net toolkit API documentation, it looks like this would work.

    Rally.RestApi Namespace 

     

    DynamicJsonObject toCreate = new DynamicJsonObject();
    toCreate["TestCase"] = "/testcase/<TestCase OID>";
    toCreate["Workspace"] = "/workspace/<Workspace OID>";
    toCreate["Build"] = "9";
    toCreate["Verdict"] = "Pass";
    toCreate["Date"] = "2016-05-09T16:14:00";
    CreateResult createResult = restApi.Create("testcaseresult", toCreate);

     

    This code snippet only uses the required attributes and workspace for TestCaseResult.

     

    Let me know if that helps.

     

    Thanks,

    Sean Davis



  • 6.  Re: Example C# REST API code to upload a Test Case Result

    Posted 03-23-2017 03:41 AM

    Ok last question...

    not understanding how to lookup the TestCase OID by starting with the TestCase ID?



  • 7.  Re: Example C# REST API code to upload a Test Case Result

    Posted 03-23-2017 08:21 AM

    Willie,

     

    I think this will get you started:

     

    long theOID = 0;

     

    Request testCaseRequest = new Request("TestCase");
    testCaseRequest.Query = new Query("FormattedID"Query.Operator.Equals, "TC1");
    testCaseRequest.Fetch = new List<string>(){"ObjectID"};

     

    QueryResult testCaseResult = restApi.Query(testCaseRequest);

     

    foreach(var result in testCaseResult.Results)
    {
      theOID = result["ObjectID"];
    }

    Console.WriteLine("ObjectID = " + theOID);

     

    Hope that helps.

     

    Michael



  • 8.  Re: Example C# REST API code to upload a Test Case Result

    Posted 03-23-2017 10:16 AM

    Works great thanks!