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 note 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 article instead, since you have access to the DB (and since the workaround explained 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 get a list of the request type keys, that are needed for this operation, first, you need to get the Issue ID of any existing issue in the relevant project, and then use it to get the values.
1. Go to your project and click on any issue
2. Edit the URL to the following format, keeping the issue key:
https://<yourinstanceurl>.atlassian.net/rest/api/2/issue/<issuekey>
3. Search for "id"
and copy its value (this id is numerical)
4. Go to the URL below to get the list of request type keys (use the issue id copied in step #3)
https://<yourinstanceurl>.atlassian.net/rest/servicedesk/1/servicedesk/request/<issueid>/request-types
Note that this is an internal endpoint that is not officially documented and can change without prior notice.
Once you get a list of the existing request types in your project, you can combine the values of "portalkey" and "key" attributes in the body of your API request as the value of the Request Type field. The correct format is "portalkey"/"key"
.
- Examples of valid values:
- "sda/getithelp"
- "sda/36fc55b4-df3e-4c73-9481-9470d545678a"
Each request type is based on an issue type and can only be selected for issues of the associated type. If the chosen request type isn't based on the correct issue type, it will result in an error.
Now, to set the value for the Request Type field when creating an issue via API, you will need the Request Type custom field id. You can get this id by accessing the address below (using any valid issue key) and searching for "Request Type":
https://<yourinstanceurl>/rest/api/2/issue/<issuekey>?expand=names
Make sure that the Customer Request Type is added to the Create issue screen
Here is a sample JSON data that works
{
"fields": {
"project": {
"id": "10205"
},
"summary": "Something's wrong",
"issuetype": {
"id": "10100"
},
"priority": {
"id": "1"
},
"components": [
{
"id": "10000"
}
],
"customfield_10202": "sda/getithelp"
}
}
We have an open Feature request to have the official REST API endpoint including the request type key:
- JSDCLOUD-4917Getting issue details... STATUS