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.


Return a json with a list of the test associated with the pre-condition.

Request

PATH PARAMETERS
parametertypedescription
preConditionKeyString

- key of the pre-condition.

Example Request

curl -H "Content-Type: application/json" -X GET -u admin:admin http://yourserver/rest/raven/1.0/api/precondition/TEST-123/test

Responses

200 OK : text/plain : Successful. Return a json.

Example Output
[{
	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.

Associate tests with the pre-condition. Return error messages, if there are any.

Request

PATH PARAMETERS
parametertypedescription
preConditionKeyString

- key of the pre-condition.

Example
Example Input
{
	"add": [
		"CALC-14",
		"CALC-29"
	],
	"remove": [
		"CALC-15",
		"CALC-50"
	]
}

Example Request

curl -H "Content-Type: application/json" -X POST -u admin:admin --data @example.json http://yourserver/rest/raven/1.0/api/precondition/TEST-123/test

Responses

200 OK : text/plain : Successful. Returns error messages if there are any.

Example Output
["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.

Remove a test from the pre-condition.

Request

PATH PARAMETERS
parametertypedescription
preConditionKeyString

- key of the pre-condition.

testKeyString- key of the test.

Example Request

curl -H "Content-Type: application/json" -X DELETE -u admin:admin http://yourserver/rest/raven/1.0/api/precondition/TEST-123/test/TEST-321
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.

  • No labels