Rally Software

 View Only
Expand all | Collapse all

How to create testcase with a browser's REST client or Soap UI in Rally

  • 1.  How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 03, 2017 02:56 AM

    I am trying to add a test case in Rally using Soap UI and the API exposed by Rally at https://rally1.rallydev.com/slm/doc/webservice/ . I am able to do that using java code though. As per the page, i need to make a POST/PUT to achieve the same but I get error

     

    {"CreateResult": {
    "_rallyAPIMajor": "2",
    "_rallyAPIMinor": "0",
    "Errors": ["Not authorized to perform action: Invalid key"],
    "Warnings": []
    }}

     

    Despite providing a valid token (key generated using https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize ) and keeping a live HTTP session, for some reason I always get the error

    Please help me fix it.

     



  • 2.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 03, 2017 04:04 PM

    Hi Chandan,

     

    To use a security token you need to append the token to the end of the URL, see example below:

    https://rally1.rallydev.com/slm/webservice/v2.0/defect/create?key=<My SecurityToken>

     

    See the Authorization section in the WSAPI documentation here:
    https://rally1.rallydev.com/slm/doc/webservice/ 

     

    Also, just wanted to let you know about APIKeys, which are a simpler alternative to security tokens. Please read the following link about APIKeys:

    CA Agile Central Application Manager | CA Agile Central Help 

     

    Let me know if that helps,

    Sean Davis



  • 3.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 03, 2017 11:01 PM

    Hi,

     

    I had tried what you have suggested earlier but I still get the same error. A sample raw request is as below :

     

    Request

     

    POST https://rally1.rallydev.com/slm/webservice/v2.0/testcase/create?key=dlGQ6YbGgcnm6pxWrVhhds48mwU2UnNxVssYndWM HTTP/1.1

    Accept-Encoding: gzip,deflate

    Content-Type: application/json

    Content-Length: 455

    Host: rally1.rallydev.com

    Connection: Keep-Alive

    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

    Cookie: JSESSIONID=qs-app-011vkksqypvczy7ngp5zwmdlhxh.qs-app-01; SERVERID=e0833b3595974942c2e7730f94e0b700cdb77178; __cfduid=dba6f46b4a3a4a9773cf98d4941ab618b1483443669

    Cookie2: $Version=1

     

     

    {

                   "testcase": {

                                  "Name": "Ignore:Newly added testcase associated to a Story3",

                                  "Description": "Test creation of Story3",

                                  "Owner": "https://rally1.rallydev.com/slm/webservice/v2.0/user/28138408395",

                                  "Objective": "Test objective of Story3",

                                  "WorkProduct": "https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/61375703434",

                                  "PreConditions": "1. Hi
    2. Hello",

                                  "Project": "17133096258",

                                  "Notes": "Adding a test case"

                   }

    }

     

    Response

     

    {"CreateResult": {

       "_rallyAPIMajor": "2",

       "_rallyAPIMinor": "0",

       "Errors": ["Not authorized to perform action: Invalid key"],

       "Warnings": []

    }}

     

    Regarding ApiKey, I have used it with Java code and it works like a charm but it doesn’t work with a rest client like Soap UI (appended ApiKey instead of key).

     

    To my understanding, it has something to do with cookies session.

     

    Thanks,

    Chandan Gupta



  • 4.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 04, 2017 11:13 AM

    Hi Chandan,

    I personally use the Postman plugin for Chrome as my REST client, so I am not familiar with SoapUI. That said, it does look like SoapUI is sending a cookie with a JSESSIONID, which might be causing the problem. With Postman you must turn on another plugin called Interceptor to send and receive cookies, which I have off by default.

     

    As for the APIKey issue. When using APIKey, you must send in the request header as a key:value pair, the following:

    ZESSIONID:<My API Key>

     

    In Postman there is a Headers tab in which you can input key/value header information. Not sure how you send header values in SoapUI. Also might need cookies disabled, but I am not sure.

     

    Let me know if that helps.

     

    -Sean Davis



  • 5.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 04, 2017 11:43 AM

    Hi Sean,

     

    I tried what you suggested with PostMan but I get the same error.

     

    The raw request from PostMan is as below:

     

    POST /slm/webservice/v2.0/testcase/create HTTP/1.1

    Host: rally1.rallydev.com

    Content-Type: application/json

    ZESSIONID: _abc123kjhs….

    Cache-Control: no-cache

    Postman-Token: 53c4ecf8-4255-6474-2ec7-3113b2a9e824

     

    {

                   "testcase": {

                                  "Name": "Ignore:Newly added testcase associated to a Story3",

                                  "Description": "Test creation of Story3",

                                  "Owner": "https://rally1.rallydev.com/slm/webservice/v2.0/user/28138408395",

                                  "Objective": "Test objective of Story3",

                                  "WorkProduct": "https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/61375703434",

                                  "PreConditions": "1. Hi
    2. Hello",

                                  "Project": "17133096258",

                                  "Notes": "Adding a test case"

                   }

    }

     

    Response :

     

    {

      "CreateResult": {

        "_rallyAPIMajor": "2",

        "_rallyAPIMinor": "0",

        "Errors": [

          "Not authorized to perform action: Invalid key"

        ],

        "Warnings": []

      }

    }

     

    If you are able to post using Postman successfully, can you share a sample raw request and response to add a test case in Rally? As the sample can help me understand the missing params or alike to fix my issue.

     

    Thanks,

    Chandan Gupta



  • 6.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 04, 2017 12:46 PM

    My apologies, I had a typo in my reply. The key should be ZSESSIONID. Try that and let me know.

     

    -Sean Davis



  • 7.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 04, 2017 01:02 PM

    Hi Sean,

     

    Thanks a lot for pointing that out. It helped. I got a test cases added successfully. Much Appreciated.

    Can I have a place when I can get the details of payloads (sample) for each operations like create, update, delete etc. The api Doc page (https://rally1.rallydev.com/slm/doc/webservice/) doesn’t have info on the payload to be passed for an operation.

     

    Thanks,

    Chandan Gupta



  • 8.  Re: How to create testcase with a browser's REST client or Soap UI in Rally
    Best Answer

    Posted Jan 06, 2017 12:35 PM

    Hi Chandan,

     

    We do not have a page that contains JSON payload examples. There are a few scattered through the Topics sections of the WSAPI documentation you reference above. I highly recommend reading all of those topics. 

     

    I personally just use the Object Model to build each payload. For example looking at HierarchicalRequirement Object, I can see if each attribute is required, and it's type. Based on that I would build the payload for a create request.

     

    To update, simply send the updated attribute specifying the OID in the URI as a POST:

    https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/ObjectID 

    {
    "Name":"My Coolest story from postman",
    "Workspace":"/workspace/<OID of workspace>"
    }

     

    To delete simply send the Object's OID in the URI as a DELETE:

    https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/ObjectID

     

    If you are ever stuck on something you can always post to this forum and we will help. Also here is a link to Stack Overflow:

    Stack Overflow: http://stackoverflow.com/questions/ask?tags=rally ( Or CA Agile as a tag)

    And here is our external KB:

    CA Agile Central Community Knowledge Base Article search: http://www.ca.com/us/services-support/ca-support/ca-support-online/support-by-product.html

     

    Hopefully that helps!

     

    -Sean Davis



  • 9.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Jan 06, 2017 12:51 PM

    Thanks Sean,

     

    Yes I realized that today and made good numbers of successful calls today. Thanks for your support and time. Appreciated!!



  • 10.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Feb 01, 2017 09:42 PM

    Hi Sean,

    I plan to add a existing user to a project. but not sure with the json object. I'm not sure how to correctly set json object up. If you has a small example of how to set it up, I would appreciate it. 



  • 11.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Feb 02, 2017 03:49 AM

    Qi Jang,

     

    There is a Knowledge Base Article,  How to create a user with Web Services API, that has an example using curl and some further information.

     

    Basically the payload is:

     

    {"User":{"UserName":"emailformat@ wsapi.com","EmailAddress":"validemail@ domain.com"}}

     

    Posted to the endpoint:

     

    https://rally1.rallydev.com/slm/webservice/v2.0/user/create 

     

    Then if you need to set specific permissions you will need to create a permission:

     

    {"ProjectPermission":{"Project":{"_ref":"/project/<ProjectOID>"},"Role":"Editor","User":{"_ref":"/user/<UserOid>"}}}

     

    Posted to the endpoint:

     

    https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission/create

     

    You'll just need to know the Object ID (OID) of the Project and use the OID of the user you just created.  There is also a Knowledge Base article, How to create ProjectPermission and add TeamMemberships with Web Services API .  It has some references to the Security Token, but you can ignore those and just use the payload pieces.

     

    Hope that helps.

     

    Michael



  • 12.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Feb 02, 2017 03:40 PM

    Hi Michael,

    How to add auth info? I got follwing message:

    { "CreateResult": { "_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": ["Not authorized to perform action: Invalid key"], "Warnings": [] } }

     

    I also did try with endpoint https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission/create?key=_sdksjflsjfsljdfsijfosijfiosidjfisdojfosidjfoisdf.

     

    Please Advise...

    Thanks

    Qi



  • 13.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Feb 07, 2017 06:06 AM

    Qi,

     

    You will need to set your API Key as a Header "zsessionid".  The How to create a user with Web Services API article shows that curl example and explains:

     

    Follow the same syntax after replacing placeholder _abc123 with a valid API Key of a user who has sufficient permissions (subscription or workspace admin) to create new users.

     

    curl --header "zsessionid:_abc123" -H "Content-Type: application/json" -d"{\"User\":{\"UserName\":\"nicktemp123@wsapi.com\",\"EmailAddress\":\"validemail@domain.com\"}}" https://rally1.rallydev.com/slm/webservice/v2.0/User/create

     

    So in your browser REST client or SOAP UI be sure to set a "zsessionid" Header with the valid API Key.

     

    Hope that helps.

     

    Michael



  • 14.  Re: How to create testcase with a browser's REST client or Soap UI in Rally

    Posted Feb 07, 2017 06:17 AM

    Qi,

     

    You may also want to check out this article, WS API request examples using curl and browser REST client.

     

    Michael