Developer Portal for YouTrack and Hub Help

400 Bad Request When Creating an Issue Without Required Field Value

This article examines an error that happens when you create an issue in a project without providing a value for a custom field that is required in this project.

When a project has a custom field that cannot be empty and doesn't have a default value, you must always set the value of this custom field when creating new issues in this project. If you don't provide the value for this custom field, you face the error described in this article.

Error Message

{ "error": "Field required", "error_description": "Type is required", "error_field": "Type", "error_rule_name": "@jetbrains/required-custom-fields-feature", "error_issue_id": "99-995", "error_issue_is_draft": false, "error_transitions": [], "error_original_command": "", "error_project_custom_field_id": "82-51", "error_type": "workflow", "error_workflow_type": "require" }

Request Details

Here are the details about a sample request that might result in this error.

Attribute

Value

Request method

POST

Endpoint

/api/issues

Request body

{ "summary": "Houston!", "description": "We have a problem!", "project": { "id": "81-6" } }

HTTP response code

400

Troubleshooting

Here are possible causes and suggestions on how to overcome this error and create an issue in the target project.

Cause

The custom field settings in the project are configured so that the custom field cannot be empty, but the default value for the field is not set. With this setup, you must always provide a value for this custom field when creating new issues in this project. You get this error when you create an issue but don't provide a value for this custom field.

Solution

Include a value for the custom field In the request body.

To find out which custom field, refer to the error message or the custom field settings in the project. In our case, the Type custom field is missing a value, as indicated in the error message: "error_description": "Type is required".

To provide the value for the Type field in the issue, you need to know the ID for the corresponding IssueCustomField. To learn this ID, send a request to one of the issues in the same project and request the custom field information.

The following body for the POST request will create an issue and return the 200 code:

{ "summary": "Houston!", "description": "We have a problem!", "project": { "id": "81-6" }, "customFields": [ { "value": { "name": "Bug" }, "name": "Type", "id": "92-1", "$type": "SingleEnumIssueCustomField" } ] }
Last modified: 15 March 2024