0

我正在尝试使用 Xray REST API 创建测试。在创建时,我还尝试将测试用例添加到已经存在的测试集中。

这是我的 POST 输入 json。

{
    "fields": {
       "project":
       {
          "key": "TEAM"
       },
       "summary": "Sum of two numbers-1",
       "description": "example of manual test-1",
       "issuetype": {
          "name": "Test"
       },

       "customfield_23240": { "value": "Manual" },             
       "customfield_23244": {
            "steps": [
                {
                    "index": 0,
                    "step": "Step 1",
                    "data": "input Data 1",
                    "result": "Excepted result 1"
                },
                {
                    "index": 1,
                    "step": "Step 2",
                    "data": "input Data 2",
                    "result": "Excepted result 2"                     
                },
                {
                    "index": 2,
                    "step": "Step 3",
                    "data": "input Data 3",
                    "result": "Excepted result 3"                     
                },
                {
                    "index": 3,
                    "step": "Step 4",
                    "data": "input Data 4",
                    "result": "Excepted result 4"                     
                }
            ]
        },
        "customfield_23246": {
            "set": [
                "TEAM-12"
            ]
        }   
   }
}

我已经仔细检查了自定义字段 ID,它们是正确的。

这是我正在运行的命令

curl -H "Content-Type: application/json" -X POST --data @test-1.json  -u user:pwd https://myserver/rest/api/2/issue

但我收到 http 500 错误。

{"errorMessages":["Internal server error"],"errors":{}}

我是在做错什么,还是在做一些 API 不支持的事情。从 X 射线文档中我不清楚。

4

1 回答 1

0

经过长时间的反复试验,终于找到了正确的json要贴出来。现在感觉很傻,因为我知道答案,但我花了几个小时才终于找到正确的输入 json。

{
    "fields": {
       "project":
       {
          "key": "TEAM"
       },
       "summary": "Sum of two numbers-1",
       "description": "example of manual test-1",
       "issuetype": {
          "name": "Test"
       },

       "customfield_23240": { "value": "Manual" },             
       "customfield_23244": {
            "steps": [
                {
                    "index": 0,
                    "step": "Step 1",
                    "data": "input Data 1",
                    "result": "Excepted result 1"
                },
                {
                    "index": 1,
                    "step": "Step 2",
                    "data": "input Data 2",
                    "result": "Excepted result 2"                     
                },
                {
                    "index": 2,
                    "step": "Step 3",
                    "data": "input Data 3",
                    "result": "Excepted result 3"                     
                },
                {
                    "index": 3,
                    "step": "Step 4",
                    "data": "input Data 4",
                    "result": "Excepted result 4"                     
                }
            ]
        },
        "customfield_23246" : ["TEAM-12"]               
   }
}
于 2020-04-18T07:02:37.707 回答