你快到了:
ArrayList tagList = new ArrayList();
DynamicJsonObject myTag = new DynamicJsonObject();
myTag["_ref"] = "/tag/2222";
tagList.Add(myTag);
myStory["Tags"] = tagList;
updateResult = restApi.Update(createResult.Reference, myStory);
此代码创建一个用户故事,根据 ref 查找标签并将标签添加到故事:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Rally.RestApi;
using Rally.RestApi.Response;
namespace Rest_v2._0_test
{
class Program
{
static void Main(string[] args)
{
//Initialize the REST API
RallyRestApi restApi;
restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");
//Set our Workspace and Project scopings
String workspaceRef = "/workspace/11111"; //replace this OID with an OID of your workspace
//Create an item
DynamicJsonObject myStory = new DynamicJsonObject();
myStory["Name"] = "abcdefg11";
CreateResult createResult = restApi.Create(workspaceRef, "HierarchicalRequirement", myStory);
DynamicJsonObject s = restApi.GetByReference(createResult.Reference, "FormattedID");
Console.WriteLine(s["FormattedID"]);
myStory["Description"] = "This is my story.";
OperationResult updateResult = restApi.Update(createResult.Reference, myStory);
ArrayList tagList = new ArrayList();
DynamicJsonObject myTag = new DynamicJsonObject();
myTag["_ref"] = "/tag/2222";
tagList.Add(myTag);
//Update the item
myStory["Tags"] = tagList;
updateResult = restApi.Update(createResult.Reference, myStory);
}
}
}