Reputation: 2104
I'm struggling with the syntax to update or create a TASK in the Rally REST API with tags.
here is my code:
//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 );
Thanks so much for any help!
Upvotes: 1
Views: 358
Reputation: 2104
Thanks to @Kyle Morse for giving me the answer to this, in the interest of completeness for anyone else who needs to do this, below is my code for CREATING a task with tags in the 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 );
Upvotes: 0
Reputation: 8400
Collections are a little tricky- you're super close. Each entry in the array needs to be an object with a _ref property rather than just the ref.
DynamicJsonObject tagObj = new DynamicJsonObject();
tagObj["_ref"] = tag._ref;
tagArray.Add(tagObj);
Upvotes: 1