How to add the form fields to the ticket create API
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
You have noticed that Atlassian released the option to add/fill Form fields in the request type during the issue/ticket creation on the RestAPI request /rest/servicedeskapi/request. This option was released on the request body parameter named "form", which is still in experimental steps.
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.
Diagnosis
According to the RestAPI documentation provided above, we must use the below JSON structure to fill the form fields on the ticket creation. However, it is not clear what is the field type on each JSON element and how to use them. So, this documentation will explain how to insert a valid JSON for the most used field types.
...
"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"
]
}
}
},
...
Solution
Firstly, contextualizing the JSON element structure, the element "1" is the form field IDs; You can get further details about what form field is associated with what ID, using the Get form on a request type API request. So, the following table shows the form field type and how is the JSON structure used to add value to the field (remember to change the field ID according to your form).
Field type | Valid JSON | Additional information |
---|---|---|
Short/Long text | "1": { | |
Date | "1": { | |
Date time | "1": { | |
"1": { | ||
Radio button | "1": { | Get the choice IDs from the API Get form on a request type |
Checkbox | "1": { | Get the choice IDs from the API Get form on a request type |
Dropdown | "1": { | Get the choice IDs from the API Get form on a request type |
User | "1": { | |
Assets object | "1":{ | Get the Assets object IDs from the API Get object {id}. The ID used in this field is the "globalId" |