public Update ( string reference, DynamicJsonObject obj ) : |
||
reference | string | the reference to be updated |
obj | DynamicJsonObject | the object fields to update |
return |
static void Main(string[] args) { RallyRestApi restApi; restApi = new RallyRestApi("*****@*****.**", "secret", "https://rally1.rallydev.com", "v2.0"); String projectRef = "/project/12352608219"; Request defectRequest = new Request("Defect"); defectRequest.Project = projectRef; defectRequest.Fetch = new List<string>() { "Name", "FormattedID", "Tasks" }; defectRequest.Query = new Query("FormattedID", Query.Operator.Equals, "DE8"); QueryResult defectResults = restApi.Query(defectRequest); String defRef = defectResults.Results.First()._ref; String defName = defectResults.Results.First().Name; Console.WriteLine(defName + " " + defRef); DynamicJsonObject defect = restApi.GetByReference(defRef, "Name", "FormattedID", "Tasks"); String taskCollectionRef = defect["Tasks"]._ref; Console.WriteLine(taskCollectionRef); ArrayList taskList = new ArrayList(); foreach (var d in defectResults.Results) { Request tasksRequest = new Request(d["Tasks"]); QueryResult tasksResult = restApi.Query(tasksRequest); foreach (var t in tasksResult.Results) { var tName = t["Name"]; var tFormattedID = t["FormattedID"]; Console.WriteLine("Task: " + tName + " " + tFormattedID); DynamicJsonObject task = new DynamicJsonObject(); task["_ref"] = t["_ref"]; taskList.Add(task); } } Console.WriteLine("Count of elements in the collection before adding a new task: " + taskList.Count); DynamicJsonObject newTask = new DynamicJsonObject(); newTask["Name"] = "another last task"; newTask["WorkProduct"] = defRef; CreateResult createResult = restApi.Create(projectRef, "Task", newTask); newTask = restApi.GetByReference(createResult.Reference, "FormattedID", "Name", "WorkProduct"); Console.WriteLine(newTask["FormattedID"] + " " + newTask["Name"] + " WorkProduct:" + newTask["WorkProduct"]["FormattedID"]); taskList.Add(newTask); Console.WriteLine("Count of elements in the array after adding a new task: " + taskList.Count); defect["Tasks"] = taskList; OperationResult updateResult = restApi.Update(defRef, defect); }
static void Main(string[] args) { RallyRestApi restApi; restApi = new RallyRestApi("*****@*****.**", "secret", "https://rally1.rallydev.com", "v2.0"); String projectRef = "/project/222"; Request testSetRequest = new Request("TestSet"); testSetRequest.Project = projectRef; testSetRequest.Fetch = new List<string>() { "Name", "FormattedID", "TestCases" }; testSetRequest.Query = new Query("FormattedID", Query.Operator.Equals, "TS22"); QueryResult queryTestSetResults = restApi.Query(testSetRequest); String tsRef = queryTestSetResults.Results.First()._ref; String tsName = queryTestSetResults.Results.First().Name; Console.WriteLine(tsName + " " + tsRef); DynamicJsonObject testSet = restApi.GetByReference(tsRef, "FormattedID", "TestCases"); String testCasesCollectionRef = testSet["TestCases"]._ref; Console.WriteLine(testCasesCollectionRef); ArrayList testCasesList = new ArrayList(); foreach (var ts in queryTestSetResults.Results) { Request tcRequest = new Request(ts["TestCases"]); QueryResult queryTestCasesResult = restApi.Query(tcRequest); foreach (var tc in queryTestCasesResult.Results) { var tName = tc["Name"]; var tFormattedID = tc["FormattedID"]; Console.WriteLine("Test Case: " + tName + " " + tFormattedID); DynamicJsonObject aTC = new DynamicJsonObject(); aTC["_ref"] = tc["_ref"]; testCasesList.Add(aTC); //add each test case in the collection to array 'testCasesList' } } Console.WriteLine("count of elements in the array before adding a new tc:" + testCasesList.Count); DynamicJsonObject anotherTC = new DynamicJsonObject(); anotherTC["_ref"] = "/testcase/123456789"; //any existing test to add to the collection testCasesList.Add(anotherTC); Console.WriteLine("count of elements in the array:" + testCasesList.Count); testSet["TestCases"] = testCasesList; OperationResult updateResult = restApi.Update(tsRef, testSet); }
static void Main(string[] args) { RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0"); String apiKey = "_abc123"; restApi.Authenticate(apiKey, "https://rally1.rallydev.com", allowSSO: false); String workspaceRef = "/workspace/1011574887"; //non-default workspace of the user String projectRef = "/project/1791269111"; //a non-default project of the user (inside the workspace above) try { //create testset DynamicJsonObject myTestSet = new DynamicJsonObject(); myTestSet["Name"] = "important set " + DateTime.Now; myTestSet["Project"] = projectRef; CreateResult createTestSet = restApi.Create(workspaceRef, "TestSet", myTestSet); myTestSet = restApi.GetByReference(createTestSet.Reference, "FormattedID", "Project"); Console.WriteLine(myTestSet["FormattedID"] + " " + myTestSet["Project"]._refObjectName); //find current iteration Request iterationRequest = new Request("Iteration"); iterationRequest.Project = projectRef; iterationRequest.ProjectScopeDown = false; iterationRequest.ProjectScopeUp = false; iterationRequest.Fetch = new List<string>() { "ObjectID", "Name" }; iterationRequest.Query = new Query("(StartDate <= Today)").And(new Query("(EndDate >= Today)")); QueryResult queryResults = restApi.Query(iterationRequest); if (queryResults.TotalResultCount > 0) { Console.WriteLine(queryResults.Results.First()["Name"] + " " + queryResults.Results.First()["ObjectID"]); myTestSet["Iteration"] = queryResults.Results.First()._ref; OperationResult updateResult = restApi.Update(myTestSet["_ref"], myTestSet); } else { Console.WriteLine("No current iterations"); } } catch (Exception e) { Console.WriteLine(e); } }
static void Main(string[] args) { RallyRestApi restApi = new RallyRestApi("*****@*****.**", "secret", "https://rally1.rallydev.com", "v2.0"); String workspaceRef = "/workspace/11111"; //use valid workspace OID in your Rally String projectRef = "/project/12345"; //use valid project OID in your Rally String userRef = "/user/777"; DynamicJsonObject d = new DynamicJsonObject(); d["Name"] = "some bug"; d["Project"] = projectRef; d["Owner"] = userRef; CreateResult createResult = restApi.Create(workspaceRef, "Defect", d); DynamicJsonObject defect = restApi.GetByReference(createResult.Reference, "FormattedID"); Console.WriteLine(defect["FormattedID"]); //update defect defect["Description"] = "bad bug"; OperationResult updateResult = restApi.Update(defect["_ref"], defect); }
static void Main(string[] args) { RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0"); String apiKey = "_abc123"; restApi.Authenticate(apiKey, "https://rally1.rallydev.com", allowSSO: false); String projectRef = "/project/32904827032"; try { //create story DynamicJsonObject myStory = new DynamicJsonObject(); myStory["Name"] = "another story " + DateTime.Now; myStory["Project"] = projectRef; CreateResult createStory = restApi.Create(workspaceRef, "HierarchicalRequirement", myStory); myStory = restApi.GetByReference(createStory.Reference, "FormattedID", "Project"); //update story myStory["Description"] = "updated " + DateTime.Now; myStory["c_CustomString"] = "abc123"; Console.WriteLine("--------------------"); Console.WriteLine(myStory["FormattedID"]); OperationResult updateResult = restApi.Update(myStory["_ref"], myStory); //create tasks for (int i = 1; i <= 3; i++) { DynamicJsonObject myTask = new DynamicJsonObject(); myTask["Name"] = "task " + i + DateTime.Now; myTask["State"] = "In-Progress"; myTask["WorkProduct"] = myStory["_ref"]; CreateResult createTask = restApi.Create(workspaceRef, "Task", myTask); myTask = restApi.GetByReference(createTask.Reference, "FormattedID", "Owner", "State"); Console.WriteLine(myTask["FormattedID"]); } } catch (Exception e) { Console.WriteLine(e); } }
static void Main(string[] args) { RallyRestApi restApi = new RallyRestApi(webServiceVersion: "v2.0"); String apiKey = "_abc777"; restApi.Authenticate(apiKey, "https://rally1.rallydev.com", allowSSO: false); String workspaceRef = "/workspace/123"; String projectRef = "/project/134"; DynamicJsonObject badDefect = new DynamicJsonObject(); badDefect["Name"] = "bad defect 2" + DateTime.Now; badDefect["Project"] = projectRef; CreateResult createRequest = restApi.Create(workspaceRef, "Defect", badDefect); badDefect = restApi.GetByReference(createRequest.Reference, "FormattedID", "Project", "State"); Console.WriteLine(badDefect["FormattedID"] + " " + badDefect["Project"]._refObjectName + " " + badDefect["State"]); badDefect["State"] = "Open"; OperationResult updateRequest = restApi.Update(badDefect["_ref"], badDefect); Console.WriteLine("Success? " + updateRequest.Success); Console.WriteLine("updated State: " + badDefect["State"]); }