Create Requirements
Create a requirement tree in the release node
Use the following operation:
POST /flex/services/rest/latest/requirementtree/add
Request format
To create a requirement in a release node, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/requirementtree/add
Request body
{
"name": "Node1",
"description": "",
"type": "req",
"releaseIds": [
"1"
],
"parentId": 0,
"projectId": 1
}
parentId - pass 0 when creating under the release node.
releaseIds - the ID of the release where the requirement folder should be created.
Response body
{
"id" : 7,
"name" : "Node1",
"description" : "",
"projectId" : 1,
"parentId" : 0,
"categories" : [ ],
"requirements" : [ ],
"releaseIds" : [ 1 ],
"releaseId" : 1,
"type" : "req"
}
Create a requirement tree sub-folder
Use the following operation:
POST /flex/services/rest/latest/requirementtree/add
Request format
To create a requirement tree sub-folder, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/requirementtree/add
Request body
{
"name": "Sub Folder",
"description": "",
"type": "req",
"releaseIds": [
"1"
],
"parentId": 7,
"projectId": 1
}
parentId - pass the ID of the parent folder where a sub-folder should be created.
Response body
{
"id" : 8,
"name" : "Sub Folder",
"description" : "",
"projectId" : 1,
"parentId" : 7,
"categories" : [ ],
"requirements" : [ ],
"releaseIds" : [ 1 ],
"releaseId" : 1,
"type" : "req"
}
Create a requirement
Use the following operation to create a requirement in Zephyr Enterprise:
POST /flex/services/rest/latest/requirement
Request format
To create a requirement, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/requirement
Request body
{
"requirementTreeId": 7,
"name": "Untitled requirement",
"details": "requirement details",
"createdBy": 1,
"lastModifiedBy": 1,
"requirementType": 0,
"testcaseIds": [],
"releaseIds": [
1
],
"customProperties": null
}
requirementTreeId - the ID of the tree where the requirement will be created.
Response body
{
"customProperties" : { },
"customProcessedProperties" : { },
"id" : 1,
"requirementTreeId" : 7,
"name" : "Untitled requirement",
"details" : "requirement details",
"createdOn" : 1594991430176,
"reqCreationDate" : "07/17/2020",
"createdBy" : 1,
"lastModifiedBy" : 1,
"lastModifiedOn" : 1594991430206,
"createDatetime" : 1594991430195,
"requirementType" : 0,
"testcaseIds" : [ ],
"testcaseVersionIds" : [ ],
"releaseIds" : [ 1 ],
"requirementTreeIds" : [ 7, 9 ],
"requirementReleaseTestcaseCountMapping" : [ ],
"projectId" : 1,
"customFieldProcessed" : false,
"customFieldValues" : [ ],
"releaseNames" : [ ],
"isBddSupported" : false,
"actualTestcaseIds" : [ ]
}
Update a requirement
Use the following operation to update a requirement in Zephyr Enterprise:
PUT /flex/services/rest/latest/requirement/{id}
{id} - the requirement ID.
Request format
To update a requirement, send a PUT request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/requirement/{id}
Sample request body
{
"attachmentCount": 0,
"actualTestcaseIds": [],
"requirementTreeId": 7,
"name": "Updated Requirement",
"details": "requirement details",
"externalId": "AltId:1",
"url": "http://localhost/",
"priority": 1,
"id": 1,
"releaseIds": [
"1"
],
"customProperties": {},
"customProcessedProperties": {},
"createdBy": 1,
"createdOn": 1594924200000,
"reqCreationDate": "07/17/2020",
"testcaseIds": [],
"requirementType": 0,
"requirementReleaseTestcaseCountMapping": [],
"projectId": 1
}
Sample response
1
Link the test case to requirements
You can do this in one of the following ways:
Map a single test case to a single requirement
Use the following operation:
POST /flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
testcaseid - the ID of the test case version.
releaseid - the release ID.
Request format
To map a single test case to a single requirement, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
Sample request
{
"modRequirementTree": [
[
10,
0
]
],
"testcaseid": 192,
"modRequirement": [
[
10,
2
]
],
"releaseId": 4
}
In this request, 10
is the requirement tree ID, and 2
is the requirement ID.
Sample response
[ 2 ]
Map a single test case to multiple requirements
Use the following operation:
POST /flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
testcaseid - the ID of the test case version.
releaseid - the release ID.
Request format
To map a single test case to multiple requirements, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
Sample request
{
"modRequirementTree": [
[
10,
0
]
],
"testcaseid": 25,
"modRequirement": [
[
10,
2
],
[
10,
3
]
],
"releaseId": 4
}
In this request, 10
is the requirement tree ID; 2
and 3
are requirement IDs.
Sample response
[ 2, 3 ]
Map a single test case to requirements from multiple nodes
Use the following operation:
POST /flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
testcaseid - the ID of the test case version.
releaseid - the release ID.
Request format
To map a single test case to requirements from multiple nodes, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
Sample request
{
"modRequirementTree": [
[
10,
0
],
[
11,
0
]
],
"testcaseid": 26,
"modRequirement": [
[
10,
4
],
[
11,
7
]
],
"releaseId": 4
}
In this request, 10
and 11
are requirement tree IDs. 4
and 7
are requirement IDs.
Sample response
[ 4, 7 ]
Map multiple test cases to multiple requirements
Use the following operation:
POST /flex/services/rest/latest/testcase/allocate/requirement?releaseid={id}&tcrCatalogTreeId={id}
Request format
To map multiple test cases to multiple requirements, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/allocate/requirement?releaseid={id}&tcrCatalogTreeId={id}
releaseid - the release ID.
tcrCatalogTreeId - the ID of the tree where the test case resides.
Sample request
{
"selectedAll": 1,
"modRequirementTree": [
[
11,
0
],
[
10,
0
]
],
"testcaseids": [
196,
195
],
"modRequirement": [
[
10,
5
],
[
10,
6
]
],
"releaseId": 4,
"override": false
}
testcaseid - the ID of the test case version.
10
and 11
are requirement tree IDs. 5
and 6
are requirement IDs.
Sample response
{
"195" : [ 5, 6 ],
"196" : [ 5, 6 ]
}
Map a single test case to the entire Requirements node
Use the following operation:
POST /flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
Request format
To map a single test case to the entire Requirements node, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/allocate/requirement/{testcaseid}?releaseid={id}
testcaseid - the ID of the test case version.
releaseid - the ID of the release.
Sample request
{
"modRequirementTree": [
[
10,
0
],
[
11,
2
]
],
"testcaseid": 198,
"modRequirement": [],
"releaseId": 4
}
In [11, 2]
, 2
is specified to map the entire node.
In [10, 0]
, 0
indicates that no requirement is mapped to the test case in the node with the ID 10.
Sample response
[ 7, 8, 9, 10, 11 ]
Synchronize requirements
Use the following operation to synchronize requirements in Zephyr Enterprise:
POST /flex/services/rest/latest/externalrequirement/importall?projectId={id}
projectId - the ID of the project.
Request format
To synchronize requirements, send a POST request to the following URL:
http://{ZEPHYR-SERVER}/flex/services/rest/latest/externalrequirement/importall?projectId={id}
Sample request
{
"projectId": 1,
"importExternalRequirementDTO": {
"projectId": 1,
"topFolderName": "",
"jiraSync": true
},
"searchStringDTO": {
"searchString": "Project = \"zs-development\""
},
"filterSearch": false,
"filterName": "",
"filterId": null,
"jiraSyncId": "",
"releaseId": "1",
"bugs": [],
"importAll": true
}
searchString - a Jira query for importing requirements.
Sample response
Successfully imported total 19 requirements
See Also