This example demonstrates plugging a gap in the official REST API. There is no way to create a new priority object.
Most of this code is involved with validating the JSON that is passed to it. The validation ensures that all required fields for a priority object are present. The appropriate method on the
response class sends the right status code. The status code is
500 (server error) if the priority already exists. The status code is
201 (created) if the priority is created.
To test, you could use the following code:
curl -X POST -H "Content-type: text/json" -u admin:admin --data "@priority.json" \ <jira_base_url>/rest/scriptrunner/latest/custom/priority
priority.json is a text file that contains:
You can have multiple methods with the same name in the same file, which is useful to do simple CRUD REST APIs.
POST /priority - creates a priority PUT /priority - updates a priority DELETE /priority - deletes a priority GET /priority - gets a priority
Downgrading ScriptRunner can cause REST endpoints to break due to a change in JSON format. Adaptavist does not recommend downgrading.