You can manage (i.e., create, update, delete) Pre-Conditions directly through Jira's native REST API.
The Xray REST API provides the following endpoints.
Pre-Condition Tests
To view the Test associated with a Pre-Condition you need to specify the key of the Pre-Condition you wish to view.
To associate or remove a Test from a Pre-Condition, you need to send a JSON with a list of the Test keys.
To remove a Test from a Pre-Condition you need to specify the key of the Test you wish to remove.
GET /rest/raven/1.0/api/precondition/{preConditionKey}/test
Return a json with a list of the test associated with the pre-condition.
Request
PATH PARAMETERS
parameter | type | description |
---|
preConditionKey | String | - key of the pre-condition. |
Responses
200 OK : text/plain : Successful. Return a json.
[{
key: "TEST-1",
self: "http://localhost:6080/rest/api/2/issue/19701",
reporter: "admin",
precondition: [{
preconditionKey: "TEST-4",
self: "http://localhost:6080/rest/api/2/issue/19705",
reporter: "admin",
type: "Cucumber"
}],
type: "Cucumber"
}, {
key: "TEST-2",
self: "http://localhost:6080/rest/api/2/issue/19701",
reporter: "admin",
precondition: [{
preconditionKey: "TEST-4",
self: "http://localhost:6080/rest/api/2/issue/19705",
reporter: "admin",
type: "Cucumber"
}],
type: "Cucumber"
}]
400 BAD_REQUEST : text/plain : Returns the error.
401 UNAUTHORIZED : text/plain : The Xray for JIRA license is not valid.
500 INTERNAL SERVER ERROR : text/plain : An internal error occurred getting the tests.
POST /rest/raven/1.0/api/precondition/{preConditionKey}/test
Associate tests with the pre-condition. Return error messages, if there are any.
Request
PATH PARAMETERS
parameter | type | description |
---|
preConditionKey | String | - key of the pre-condition. |
Example
{
"add": [
"CALC-14",
"CALC-29"
],
"remove": [
"CALC-15",
"CALC-50"
]
}
Responses
200 OK : text/plain : Successful. Returns error messages if there are any.
["Test with key TEST-3 was not associated with Pre-Condition with key TEST-4.","Test with key TEST-2 was already associated with Pre-Condition with key TEST-4."]
400 BAD_REQUEST : text/plain : Returns the error.
401 UNAUTHORIZED : text/plain : The Xray for JIRA license is not valid.
500 INTERNAL SERVER ERROR : text/plain : An internal error occurred associating the tests.
DELETE /rest/raven/1.0/api/precondition/{preConditionKey}/test/{testKey}
Remove a test from the pre-condition.
Request
PATH PARAMETERS
parameter | type | description |
---|
preConditionKey | String | - key of the pre-condition. |
testKey | String | - key of the test. |
Responses
200 OK : text/plain : Successful.
400 BAD_REQUEST : text/plain : Returns the error.
401 UNAUTHORIZED : text/plain : The Xray for JIRA license is not valid.
500 INTERNAL SERVER ERROR : text/plain : An internal error occurred removing the test.