Integrating Custom Form Fields into Jira Ticket Creation API
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Atlassian now allows adding form fields in ticket creation via the REST API, using the experimental "form" parameter.
Request body information
form
(Experimental) Provides answers to the form associated with a request type that is attached to the request on creation. Jira fields should be omitted from requestFieldValues
if they are linked to form answers. Form answers in ADF format should have isAdfRequest
set to true. Form answers are not currently validated.
Solution
The JSON structure for ticket creation
Based on the REST API documentation, use the JSON structure below to fill form fields when creating a ticket. This guide will clarify the field types for each JSON element and show how to use them effectively.
JSON to fill form fields
...
"form": {
"answers": {
"1": {
"text": "Answer to a text form field"
},
"2": {
"date": "2023-07-06"
},
"3": {
"time": "14:35"
},
"4": {
"choices": [
"5"
]
},
"5": {
"users": [
"qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d69abfa3980ce712caae"
]
}
}
},
...
Understanding the JSON for each field type
First, understand that the JSON element "1" represents form field IDs. To find out which form field corresponds to each ID, use theThe Forms REST APIAPI request.
The table below shows how to use the JSON structure to add values to form fields. Remember to update the field ID to match your form.
Field type | Valid JSON | Additional information |
---|---|---|
Short/Long text | "1": { "text": "Short/Long text field type" } | |
Date | "1": { "date": "2024-04-15" } | |
Date time | "1": { "date":"2024-04-16", "time":"03:30" } | |
"1": { "text": "<Email address>" } | ||
Radio button | "1": { "choices": [ "2" ] } | Get the choice IDs from the API Get form on a request type |
Checkbox | "1": { "choices": [ "3", "2" ] }, | Get the choice IDs from the API Get form on a request type |
Dropdown | "1": { "choices": [ "3" ] } | Get the choice IDs from the API Get form on a request type |
User | "1": { "users": [ "<User ID>" ] } | |
Assets object | "1":{ "choices":["<Object ID>"] } | Get the Assets object IDs from the API Get object {id}. The ID used in this field is the "globalId" |
Was this helpful?