I have a custom field that I need to include in the JSON format for creating an issue in Jira via the REST API. Could someone please provide guidance on how to structure this? Here’s an example of the custom field:
"customField_20100":{
"isMandatory":false,
"fieldSchema":{
"dataType":"option",
"type":"com.atlassian.jira.plugin.system.customfieldtypes:select",
"fieldId":20100
},
"label":"Priority",
"defaultValueExists":false,
"actions":[
"update"
],
"permissibleValues":[
{
"link":"http://example.com/rest/api/2/customFieldOption/20101",
"label":"High",
"optionId":"20101"
},
{
"link":"http://example.com/rest/api/2/customFieldOption/20102",
"label":"Medium",
"optionId":"20102"
}
]
}
When working with Jira’s REST API, sometimes the permissions settings can affect your ability to use custom fields, so double-check that your API token or credentials have the proper permissions. Also, keep in mind that certain fields might require more setup than just adding them to the JSON payload. For instance, check if your custom field needs specific context settings or default configurations within Jira itself. If your custom field is a dropdown (as per your schema), make sure you’re using the right optionId
as the value instead of text labels. A tool like Postman can be quite handy for testing your API calls and pinpointing any issues with your requests. It’s always a good idea to look at examples on how existing issues with custom fields are structured if you’re migrating or replicating them programmatically.
To include a custom field when creating a Jira issue through the REST API, you’ll need to identify the field ID and structure it within your JSON payload properly. First, ensure you have the correct ID for your custom field, as shown in your example (customField_20100
). Ensure the field is part of the fields
object in your JSON payload when making a POST request to the issue
API endpoint. It should look something like this:
{
"fields": {
"project": {
"key": "YOUR_PROJECT_KEY"
},
"summary": "Issue Summary",
"issuetype": {
"id": "YOUR_ISSUETYPE_ID"
},
"customfield_20100": {
"value": "HIGH"
}
}
}
Make sure the value
matches one of the label
values you defined previously. Also, ensure you include mandatory fields like summary
or project
.
Make your API request using the correct credentials, usually through Basic Auth or OAuth, depending on your setup. Double-check API documentation for any nuances specific to custom fields in your Jira version.