在 Rally C# API 中添加标签(到 userStory 或 Task)
Add tags in Rally C# API ( to userStory or Task)
我正在为使用标签在 Rally REST API 中更新或创建任务的语法而苦苦挣扎。
这是我的代码:
//Tag Holder
ArrayList tagArray = new ArrayList();
tagArray.Add(tag._ref);
//the Task itself
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["WorkProduct"] = storyRef;
//i need to pass the tags as a parameter
NameValueCollection parameters = new NameValueCollection();
//this is where I am stuck, how do I attach the tags to the parameters
//call the API to create the task
CreateResult resultX = api.Create("task", toCreate, parameters );
非常感谢您的帮助!
Collections 有点棘手 - 你非常接近。数组中的每个条目都需要是带有 _ref 属性 的 object 而不仅仅是 ref.
DynamicJsonObject tagObj = new DynamicJsonObject();
tagObj["_ref"] = tag._ref;
tagArray.Add(tagObj);
感谢@Kyle Morse 给我这个问题的答案,为了其他任何需要这样做的人的完整性,下面是我在 Rally 中创建带有标签的任务的代码 API
//task object
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["WorkProduct"] = storyRef;
//Tag Holder
ArrayList tagArray = new ArrayList();
//loop through your tags
foreach(tag in tags)
{
DynamicJsonObject tagObj = new DynamicJsonObject();
tagObj["_ref"] = tag._ref;
tagArray.Add(tagObj);
}
//this is where you attach the tags
toCreate["Tags"] = tagArray;
//call the API to create the task
CreateResult result = api.Create(WorkSpace._ref,"task", toCreate );
我正在为使用标签在 Rally REST API 中更新或创建任务的语法而苦苦挣扎。
这是我的代码:
//Tag Holder
ArrayList tagArray = new ArrayList();
tagArray.Add(tag._ref);
//the Task itself
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["WorkProduct"] = storyRef;
//i need to pass the tags as a parameter
NameValueCollection parameters = new NameValueCollection();
//this is where I am stuck, how do I attach the tags to the parameters
//call the API to create the task
CreateResult resultX = api.Create("task", toCreate, parameters );
非常感谢您的帮助!
Collections 有点棘手 - 你非常接近。数组中的每个条目都需要是带有 _ref 属性 的 object 而不仅仅是 ref.
DynamicJsonObject tagObj = new DynamicJsonObject();
tagObj["_ref"] = tag._ref;
tagArray.Add(tagObj);
感谢@Kyle Morse 给我这个问题的答案,为了其他任何需要这样做的人的完整性,下面是我在 Rally 中创建带有标签的任务的代码 API
//task object
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate["WorkProduct"] = storyRef;
//Tag Holder
ArrayList tagArray = new ArrayList();
//loop through your tags
foreach(tag in tags)
{
DynamicJsonObject tagObj = new DynamicJsonObject();
tagObj["_ref"] = tag._ref;
tagArray.Add(tagObj);
}
//this is where you attach the tags
toCreate["Tags"] = tagArray;
//call the API to create the task
CreateResult result = api.Create(WorkSpace._ref,"task", toCreate );