How to set Request Type when creating an issue via REST API using /rest/api/2/issue endpoint
Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article explains the JSON data required to set the customer request type when creating an issue via the /rest/api/2/issue REST endpoint (from Jira).
Read the caveat section at the end for a heads-up comparison to Jira Service Management API.
Environment
Jira Core 7.x and 8.x with Jira Service Management 3.x or 4.x.
This article applies to Atlassian apps on the Data Center platform. It was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions, but they have not been tested. Support for Server products ended on February 15th 2024.
Solution
Identify the custom field ID for the Request Type custom field.
Use that ID in the JSON as
customfield_<ID>. For example, if the custom field ID is10202, usecustomfield_10202.Set the value as the project key combined with the value from the
KEYcolumn in theAO_54307E_VIEWPORTFORMtable. Valid examples includesda/getithelpandsda/cc54f9a4-11bc-4783-a32e-382ff1840eb2.If the project was renamed, use the original project key as the prefix for the Customer Request Type value.
If the valid Customer Request Type value is unknown, create the desired issue type through the service project portal and copy the value from the Customer Request Type field. The existing query can then be used with the recently created issue key to retrieve the value:
select v.stringvalue from jiraissue i join project p on p.id = i.project join customfieldvalue v on v.issue = i.id where p.pkey = 'SDA' and i.issuenum = 1234; -- replace by the issue key recently created
Make sure that the Customer Request Type is added to the create issue screen.
Use the following existing example as the complete request-body pattern:
{ "fields": { "project": { "id": "10205" }, "summary": "Something's wrong", "issuetype": { "id": "10100" }, "priority": { "id": "1" }, "components": [ { "id": "10000" } ], "customfield_10202": "sda/getithelp" } }
Caveat
Jira Service Management can set default values for hidden fields for each Request Type. Creating issues through Jira's /rest/api/2/issue endpoint does not follow those configurations; it proceeds according to the JSON only. As a result, API-created issues may diverge from portal-created ones and may require additional hidden values to be set.
If inheriting the hidden-field default values for the given Request Type is required, consider the Jira Service Management REST API endpoint /rest/servicedeskapi/request instead.
Was this helpful?