3

I am new to the Rally API and just having some trouble creating a Task using the Rally.RestApi library. I need to create a Task (using .NET) and associate it with a User Story (in which the User Story belongs to a certain Iteration).

Do I have to get the User Story first, then add a Task to it? How would I do that?

Thanks.

Kyle Morse
  • 8,390
  • 2
  • 15
  • 16
robnardo
  • 921
  • 11
  • 27

1 Answers1

3

All objects in Rally have a unique url called a ref. You just need the story's ref to associate the two:

RallyRestApi restApi = new RallyRestApi("myuser@company.com", "password",
    "https://rally1.rallydev.com", "1.27");
DynamicJsonObject newTask = new DynamicJsonObject();
newTask["Name"] = "My New Task";
newTask["WorkProduct"] = "/hierarchicalrequirement/12345"; //your story ref here
CreateResult createResult = restApi.Create("task", newTask);
Kyle Morse
  • 8,390
  • 2
  • 15
  • 16
  • Hey Kyle, thanks for prompt answer. Just wondering, should the last line be restApi.Create("tasks", newTask); ? – robnardo Oct 19 '11 at 20:22
  • Good catch! I adapted that snippet from a defect creation example and missed the last line. It's fixed now. – Kyle Morse Oct 19 '11 at 20:48
  • 1
    Thanks. Another question: what fields (other than toCreate["Name"]) are available for Task creation? – robnardo Oct 20 '11 at 13:28
  • FYI - to query for User Story by Iteration Name and User Story Name, use: rally1.rallydev.com/slm/webservice/1.27/hierarchicalrequirement?query=((Name = "User Story Name Here") and (Iteration.Name = "Iteration_Name_Here"))&fetch=true – robnardo Oct 20 '11 at 17:05
  • 1
    Check out the interactive Web Services API documentation here: https://rally1.rallydev.com/slm/doc/webservice/ You can browse all the available objects exposed and their fields and even test out queries against them. – Kyle Morse Oct 21 '11 at 23:14
  • I am getting an error on the Create method. Error is: KeyNotFoundException, The given key was not present in the dictionary. – robnardo Oct 29 '11 at 23:57