使用Soap UI -Rest

时间:2017-01-02 12:27:24

标签: json rest soapui rally

我正在尝试使用Soap UI和Rally在https://rally1.rallydev.com/slm/doc/webservice/公开的API在Rally中添加测试用例。我可以使用java代码来做到这一点。根据页面,我需要做一个POST / PUT来实现相同但我得到错误

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

我传递的有效载荷如下

 {
        "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"
    }

请帮我解决问题。

添加样本请求

POST https://rally1.rallydev.com/slm/webservice/v2.0/testcase/create?key=abc123 ..... HTTP / 1.1 Accept-Encoding:gzip,deflate Content-Type:application / json 内容长度:464 主持人:rally1.rallydev.com 连接:保持活力 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 个答案:

答案 0 :(得分:0)

SOAP UI客户端是否管理cookie?您需要确保仍然使用相同的会话来处理所有请求。通过key查询字符串参数传递的身份验证令牌需要与活动会话匹配。如果您的请求只是再次重新传递基本身份验证凭据,则可能会生成新会话,导致该令牌无效。通常在客户端启用cookie就足以解决这个问题。这就是我们提供的工具包管理它的方式。

答案 1 :(得分:0)

我能够成功地将测试用例添加到Rally中的用户故事中。我们要做的是添加标题为&#34; ZSESSIONID&#34;在&#34; https://rally1.rallydev.com/login/accounts/index.html#/keys&#34;创建的ApiKey值在POST请求中。感谢大家的支持