ALM 使用 JSON 有效负载 (REST API) 创建新的测试运行
Posted
技术标签:
【中文标题】ALM 使用 JSON 有效负载 (REST API) 创建新的测试运行【英文标题】:ALM create new Test Run using JSON payload ( REST API) 【发布时间】:2020-02-04 22:21:42 【问题描述】:
"entities": [
"Type": "run",
"Fields": [
"values": [
"value": "Run_10_07_2019_11_13_53_12345"
],
"Name": "name"
,
"values": [
"value": "1"
],
"Name": "test-instance"
,
"values": [
"value": "12345"
],
"Name": "testcycl-id"
,
"values": [
"value": "56789"
],
"Name": "cycle-id"
,
"values": [
"value": "23456"
],
"Name": "test-id"
,
"values": [
"value": "hp.qc.test-instance.EXTERNAL"
],
"Name": "subtype-id"
,
"values": [
"value": "Passed"
],
"Name": "status"
,
"values": [
"value": "novice"
],
"Name": "owner"
]
]
输出 "Id": "qccore.general-error", “标题”:“一般错误”, “异常属性”:空, “堆栈跟踪”:空 500 内部服务器错误
我正在尝试使用 REST API for ALM EndPoint 创建测试运行
POST /qcbin/rest/domains/domain/projects/project/runs
Content-Type: application/json
Accept: application/json
Cookie: QCSession=xxx; LWSSO_COOKIE_KEY=xxx
有人可以帮我解决这个问题吗?
【问题讨论】:
有人对这个问题有什么建议吗? 【参考方案1】:您的请求(方法、标头、URL)看起来正确。
但您的数据/JSON 不得包含“多实体”文档(以“实体”开头)。
改为将其更改为仅包含 1 个运行实体,如下所示。
"Fields": [
"Name": "test-id",
"values": [
"value": "843"
]
,
"Name": "test-name",
"values": [
"value": "d1"
]
,
"Name": "has-linkage",
"values": [
"value": "N"
]
,
"Name": "path",
"values": [
]
,
"Name": "cycle-id",
"values": [
"value": "1"
]
,
"Name": "vc-version-number",
"values": []
,
"Name": "draft",
"values": [
"value": "N"
]
,
"Name": "host",
"values": [
"value": "WS-123456"
]
,
"Name": "id",
"values": [
"value": "1"
]
,
"Name": "state",
"values": [
]
,
"Name": "test-config-id",
"values": [
"value": "1234"
]
,
"Name": "ver-stamp",
"values": [
"value": "2"
]
,
"Name": "iters-params-values",
"values": [
]
,
"Name": "os-build",
"values": [
"value": "Build 123456"
]
,
"Name": "os-sp",
"values": [
]
,
"Name": "name",
"values": [
"value": "Run_11-25_9-51-41"
]
,
"Name": "testcycl-name",
"values": [
"value": "d1 [1]"
]
,
"Name": "status",
"values": [
"value": "Not Completed"
]
,
"Name": "os-config",
"values": [
]
,
"Name": "vc-locked-by",
"values": [
]
,
"Name": "bpt-structure",
"values": [
]
,
"Name": "cycle",
"values": [
]
,
"Name": "execution-date",
"values": [
"value": "2019-11-25"
]
,
"Name": "duration",
"values": [
"value": "4"
]
,
"Name": "last-modified",
"values": [
"value": "2019-11-25 09:51:46"
]
,
"Name": "subtype-id",
"values": [
"value": "hp.qc.run.MANUAL"
]
,
"Name": "attachment",
"values": [
]
,
"Name": "test-description",
"values": [
]
,
"Name": "assign-rcyc",
"values": [
]
,
"Name": "text-sync",
"values": [
]
,
"Name": "owner",
"values": [
"value": "john_doe"
]
,
"Name": "pinned-baseline",
"values": [
]
,
"Name": "comments",
"values": [
]
,
"Name": "iters-sum-status",
"values": [
]
,
"Name": "bpta-change-detected",
"values": []
,
"Name": "test-instance",
"values": [
"value": "1"
]
,
"Name": "cycle-name",
"values": [
"value": "ts"
]
,
"Name": "os-name",
"values": [
"value": "Windows 10"
]
,
"Name": "user-template-07",
"values": []
,
"Name": "environment",
"values": [
]
,
"Name": "vc-status",
"values": [
]
,
"Name": "execution-time",
"values": [
"value": "09:51:46"
]
,
"Name": "bpta-change-awareness",
"values": [
]
,
"Name": "user-template-01",
"values": [
]
,
"Name": "user-template-02",
"values": [
]
,
"Name": "user-template-03",
"values": []
,
"Name": "user-template-04",
"values": [
]
,
"Name": "user-template-05",
"values": [
]
,
"Name": "testcycl-id",
"values": [
"value": "1"
]
,
"Name": "user-template-06",
"values": []
],
"Type": "run",
"children-count": 0
(只是一个示例 - 您可能需要更新字段名称和值以匹配您的特定模板)。
【讨论】:
谢谢马腾。我的一位朋友帮助我解决了这个问题,它与您建议的解决方案相同。以上是关于ALM 使用 JSON 有效负载 (REST API) 创建新的测试运行的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot REST 读取 JSON 数组有效负载
在使用 SpringBoot 开发的 REST API 中映射到 Java 对象时,使 JSON 有效负载字段不区分大小写