Rally Software

 View Only
  • 1.  How to add risks to a feature via rest API

    Posted Sep 04, 2020 06:10 PM

    We can pull, create and update portfolio items via rest API.  But when creating or updating a Feature want to know how to add risks to this feature via API? or want to know Is it something doable via api?  At this point I don't know which one to update the feature or the risk?

     In the risk it shows as WorkItemsAffected and this is a RankableArtifact.

     WorkItemsAffected -> _ref points to features or any other objects affected.

    "https://rally1.rallydev.com/slm/webservice/v2.0/Risk/riskobjectId/WorkItemsAffected",

     And for Feature it's under _ref of risk object

    "https://rally1.rallydev.com/slm/webservice/v2.0/PortfolioItem/Feature/featureObjectId/Risks"

    Appreciate any help, pointers on this.

    Thanks.



  • 2.  RE: How to add risks to a feature via rest API
    Best Answer

    Broadcom Employee
    Posted Sep 08, 2020 12:05 PM
    Hi Manjula.

    You can add the Risk to the Feature by using the Feature's 'Risks' collection field. You can enter a list of Risk objects. Here is an example:

    {
       "PortfolioItem/Feature": {
          "Name":"My New Cool Feaqture from postman w Risk",
             "Risks": [
                { "_ref": "/risk/429329422488" },
                { "_ref": "/risk/423932523770" }
             ]
        }
    }

    Please let us know if that helped.

    Thanks,
    Sagi


  • 3.  RE: How to add risks to a feature via rest API

    Posted Sep 10, 2020 06:09 PM

    Thanks Sagi,
    Thanks for your reply. I'm using Rally Rest API and I was able to add risks to an existing feature via AddToCollection method. (I tried your above way to use in Rally rest API, but could not successfully add risks.)

    I'm not sure if we can do this at the same time while creating the new feature using rally rest API. If I figure it out will post here. 

    Posting the code I use, so it will help anyone looking for this. (This is C# code)

    DynamicJsonObject risk1 = new DynamicJsonObject();
    risk1["_ref"] = "/risk/risk1ObjectId";

    DynamicJsonObject risk2 = new DynamicJsonObject();
    risk2["_ref"] = "/risk/risk2ObjectId";

    string featureRef = "/portfolioitem/feature/featureObjectId";
    List<DynamicJsonObject> risks = new List<DynamicJsonObject>() { risk1, risk2 };
    OperationResult updateResult = acRestApi.AddToCollection(featureRef, "Risks", risks, null);

    if (updateResult.Success)
    {
    }
    else
    {
    }