How to set the Request Type when creating an issue using Jira REST API in Atlassian Cloud
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Purpose
This article explains the JSON data required to set the customer request type when creating a Jira Service Management request using the Jira Work Management (/rest/api/2/issue or /rest/api/3/issue) endpoint in Cloud.
However, please notice that:
- the correct (and easiest) way to create a Jira Service Management request via REST API is to use the Jira Service Management Cloud REST API 'request' endpoint: /rest/servicedeskapi/request
- if you are using Jira Server you may want to see the following HowTo instead, since you have access to the DB (and since the workaround explained in here may not apply to Server): How to set Request Type when creating an issue via REST API using /rest/api/2/issue endpoint
Solution
To set the request type via REST API, you will have to userest/servicedesk/1/servicedesk/request/ISSUE_ID/request-types the custom field ID for the Request Type custom field. For example, if the request type custom field in your instance has the id of 10202, you will have to use customfield_10202.
- As for the value, it is actually a combination of the project key and the value of the Key property for the desired request type (project-key/Key) that can be retrieved by calling the internal endpoint:
https://YOUR_HOSTNAME/rest/servicedesk/1/servicedesk/request/ISSUE_ID/request-typesAn example of a valid value is sda/getithelp
Calling to the above endpoint (or pasting it in the browser) with the correct issue ID and service Management ID of an already existing issue in the same service Management project you want to create the new issue will result in Jira returning a JSON response containing all the customer request types within the service Management, including the Key property.
Please notice that this is an internal endpoint not officially documented that can change without prior notice. We have the below Feature request opened in our system to have the official REST API endpoint to include the request-type key:
Make sure that the Customer Request Type is added to the create issue screen.
Here is a sample JSON data which works
{ "fields": { "project": { "id": "10205" }, "summary": "Something's wrong", "issuetype": { "id": "10100" }, "priority": { "id": "1" }, "components": [ { "id": "10000" } ], "customfield_10202": "sda/getithelp" } }
You'll just have to identify the custom field id and valid values and you should use for it to work.