2

Please be patient and Do Not flag this as duplicate: Using the Rally REST API, how can I get the non-API (website) URL for a user story?

I want to be able to generate a link for the user story. Something like this: https://rally1.rallydev.com/#/-/detail/userstory/********* As opposed to this: https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/88502329352

The link will be integrated into another application for the managers to see the user story. I did read about the getDetailUrl() method, but in my case I am creating the user stories by parsing email and linking that to a notification service in Slack. I am aware of the formattedID and (_ref), but I would have to query for it again, and I am creating batches of userstories through a loop. I need the actual web site link to the user story.

Here is my sample code:

public void CreateUserStory(string workspace, string project, string userstoryName){

//authenticate with Rally
this.EnsureRallyIsAuthenticated();

//DynamicJsonObject for HierarchicalRequirement
DynamicJsonObject toCreate = new DynamicJsonObject();
toCreate[RallyConstant.WorkSpace] = workspace;
toCreate[RallyConstant.Project] = project;
toCreate[RallyConstant.Name] = userstoryName;

 try
 {
    //Create the User Story Here
    CreateResult createUserStory = _api.Create(RallyConstant.HierarchicalRequirement, toCreate);
    Console.WriteLine("Created Userstory: " + "URL LINK GOES HERE");
 }
 catch (WebException e)
 {
    Console.WriteLine(e.Message);
 }
}
Community
  • 1
  • 1

1 Answers1

1

We don't have a method in the .NET toolkit for doing this, but it's easy to create.

The format is this:

https://rally1.rallydev.com/#/detail/<type>/<objectid>

Just fill in the type (hierarchicalrequirement turns into userstory, but all the others are the same as the wsapi type) and the objectid from the object you just created.

var parameters = new NameValueCollection();
parameters["fetch"] = "FormattedID";
var toCreate = new DynamicJsonObject();
var createResult = restApi.create("hierarchicalrequirement", toCreate, parameters); 
var type = Ref.getTypeFromRef(createResult.Reference);
var objectID = Ref.getOidFromRef(createResult.Reference);
var formattedID = createResult.Object["FormattedID"];

And you can specify fetch fields to be returned on the created object so you don't have to re-query for it.

Kyle Morse
  • 8,390
  • 2
  • 15
  • 16
  • Kyle: I am confused about the objectID and Type. How would I access these fields after I create the user story. I have a dynamicJSONObject, but those fields are not visible. Can you provide a code sample. Thanks – Sumanth Maddirala Mar 16 '17 at 16:04
  • i just updated the answer to include some more code to pull those values out of the response... – Kyle Morse Mar 16 '17 at 16:13
  • Is there a way to get the formattedID similar to the above code. (US111) – Sumanth Maddirala Mar 16 '17 at 16:51
  • sure, you don't need it for the url, but it should just be createResult.Object["FormattedID"], assuming you fetched it on the create... – Kyle Morse Mar 16 '17 at 17:15
  • Well I create user stories in batches, I do not pull them, but I assume there is no way of obtaining that unless I fetch. Can you fetch after a create, I do not know how the code would look like, I have code when from when I fetched all the stories from Rally. – Sumanth Maddirala Mar 16 '17 at 17:38