2
votes

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": []
}}

The payload I am passing is as below

 {
        "Name": "Ignore:Newly added testcase associated to a Story3",
        "Description": "Test creation of Story3",
        "Owner": "https://rally1.rallydev.com/slm/webservice/v2.0/user/3215613515",
        "Objective": "Test objective of Story3",
        "PreConditions": "1. Hi<br>2. Hello",
        "Project": "1223451",
        "Notes": "Adding a test case"
    }

Please help me fix the issue.

Adding a sample request

POST https://rally1.rallydev.com/slm/webservice/v2.0/testcase/create?key=abc123..... HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/json Content-Length: 464 Host: rally1.rallydev.com Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) Cookie: JSESSIONID=qs-app-07fv4cswgptt7b1vc3o58hztndw.qs-app-07; SERVERID=c1acc7f401011b9881d1497a9ef30b27acc4a1c9; __cfduid=d392a0428b5fa74f473cb1712c3d64d7a1483502577 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<br>2. Hello",
        "Project": "/project/17133096258",
        "Notes": "Adding a test case"
    }`enter code here`
}  
2
The json is valid, but probably the Rally webservice is waiting for something different. Could you check what is the webservice waiting for Which JSON which what format is the Rally webservice waiting for?tremendows
The above error is gone by following what is mentioned at "stackoverflow.com/questions/18620056/…" but now I get a different error - "Errors": ["Not authorized to perform action: Invalid key"] . FYI, I have tried with different token (newly created key).Chandan Gupta
In order to use POST to create objects, it's necessary to obtain a security key; see webservices API documentation here: rally1.rallydev.com/slm/doc/webservice/authentication.jsp. Alternatively, you may wish to use an API key instead of basic auth; see ca.com/us/services-support/ca-support/ca-support-online/…user4211235
I have tried passing the "key" as parameter as explained at rally1.rallydev.com/slm/doc/webservice/authentication.jsp but I still get the error {"CreateResult": { "_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": ["Not authorized to perform action: Invalid key"], "Warnings": [] }}Chandan Gupta
A couple minor things- your Project needs to be a ref (/project/1223451). Also your post body needs to be wrapped in another object with one key matching the type: { "testcase": { ... your object here ... }}Kyle Morse

2 Answers

0
votes

Does the SOAP UI client manage cookies? You'll need to be sure you're still using the same session for all your requests. The auth token passed via the key query string parameter needs to match the active session. If your request is just re-passing the basic auth credentials again it will probably generate a new session, rendering that token invalid. Usually enabling cookies in the client is enough to fix this. This is the way the toolkits we provide manage it.

0
votes

I was able to successfully add a test case to a user story in Rally. What we have to do is add a header as "ZSESSIONID" with a value as ApiKey created at "https://rally1.rallydev.com/login/accounts/index.html#/keys" in a POST request. Thanks everyone for the support