Rally Software

 View Only
  • 1.  How to create a new user story in Rally using Rest API

    Posted Oct 02, 2019 01:19 AM
    I am trying to create a new User Story in Rally from Salesforce Apex.
    What I tried so far.
    Got the security API using  JSON REST URI -https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize .As User story is a HierarchicalRequirement then create (PUT) using JSON REST URI   https://demo-rally.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement/create?key=  ,where key is the security token.


    Code I tried:
    endpoint = 'https://rally1.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement/create?key=Jstring';
    request.setEndPoint(endpoint);
    // Set the HTTP verb to GET.
    request.setMethod('GET');
    HttpResponse response1 = httpProtocol.send(request);

    Receiving the following error..

    21:01:26:416 USER_DEBUG [48]|DEBUG|{"QueryResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": ["Not able to parse artifact type: hierarchicalrequirement/create"], "Warnings": [], "TotalResultCount": 0, "StartIndex": 0, "PageSize": 0, "Results": []}}

    Any help is greatly apreciated..


  • 2.  RE: How to create a new user story in Rally using Rest API

    Broadcom Employee
    Posted Oct 02, 2019 09:55 AM
    Hi Regi,

    In your code you're setting your method to GET where it should be a PUT or POST

    But also, you will need to pass at least a Name attribute in addition to any required fields you may have defined on your user stories.


  • 3.  RE: How to create a new user story in Rally using Rest API

    Posted Oct 03, 2019 12:38 PM
    Hi David
    I do not have the request service contract for creating an user story.
    Could you please share one if you have one handy?

    Regi


  • 4.  RE: How to create a new user story in Rally using Rest API

    Broadcom Employee
    Posted Oct 03, 2019 01:08 PM

    Hi Regi,

    I'm not certain I understand what you mean by a "request service contract".  Are you referring to a payload?  If so, here's a sample payload:

    {
      "HierarchicalRequirement": {
        "Name": "Hello world",
        "Description": "Hello world"
      }
    }
    



  • 5.  RE: How to create a new user story in Rally using Rest API

    Posted Oct 03, 2019 07:30 PM
    Thanks David.

    I am getting a different error now.
    16:23:55:200 USER_DEBUG [54]|DEBUG|{"CreateResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": ["Not authorized to perform action: Invalid key"], "Warnings": []}}

    I passed the security api token for the PUT .
    https://rally1.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement/create?key=MGQ1CfvRYK09vAOyN1lDgLAVkkR02tlGK7tRTM58.

    The code I tried ,

    request.setEndPoint(apitoken);
    System.debug('End Point'+ apitoken);
    // Set the HTTP verb to G
    request.setBody('{"HierarchicalRequirement": { "Name": "Hello world", "Description": "Hello world","Owner": "Regi Varghese" } }');
    request.setMethod('PUT');
    HttpResponse response1= httpProtocol.send(request);
    System.debug(response1.getBody());



  • 6.  RE: How to create a new user story in Rally using Rest API
    Best Answer

    Broadcom Employee
    Posted Oct 03, 2019 09:09 PM
    Hi Regi,

    This knowledge article describes the reasons why you might encounter that error:
    https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=127054



  • 7.  RE: How to create a new user story in Rally using Rest API

    Posted Oct 17, 2019 11:11 PM
    Edited by Regi Varghese Oct 17, 2019 11:16 PM
    Thanks David.

    Great article. It helped.I used API instead of security token.

    On an other note- is it possible to send an attachment (.doc or a .xls) file along with other details  while creating an user story using rest API?

    Any help is appreciated.

    Thanks
    RV


  • 8.  RE: How to create a new user story in Rally using Rest API

    Posted Oct 17, 2019 11:15 PM
    Edited by Regi Varghese Oct 17, 2019 11:15 PM