Developer Portal for YouTrack and Hub Help

400 Bad Request When Updating a Conditional Field

This article examines an error that might occur when you update the value of a conditional custom field using the YouTrack REST API. You can face this error when you update a custom field that is hidden behind a condition and not shown in the target issue.

Error Message

{ "error": "invalid_properties", "error_description": "You can only update the value for the Estimation field when the value for the Type field is Task", "error_children": [ { "error": "Issue-is-invalid", "error_description": "You can only update the value for the Estimation field when the value for the Type field is Task", "error_developer_message": "You can only update the value for the Estimation field when the value for the Type field is Task" } ] }

Request Details

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

Attribute

Value

Request method

POST

Endpoint

/api/issues/{issueID}/customFields/{customFieldID}?fields=name,value(presentation),id

Request body

{ "value": { "presentation": "10h", "$type": "PeriodValue" }, "name": "Estimation", "id": "131-66", "$type": "PeriodIssueCustomField" }

HTTP response code

400

Use Case

You need to update the value of the Estimation custom field in an issue, but this field is only shown when the Type custom field has the Task value in the issue. For more information about conditional fields in YouTrack, see Conditional Fields.

If you try to update the value of the Estimation custom field while the Type custom field is set to the Bug value, you will get this error.

Troubleshooting

Here is a summary of the error cause and a suggestion for overcoming this error and updating the value in the target issue.

Cause

The required custom field isn't displayed in the issue because it relies on another custom field's value, which is currently set differently from what's needed to show the target field. An attempt to update a hidden custom field results in an error.

Solution

First, set the value of the Type custom field to the Task value. From the project field settings, you know that Task is the type value that allows you to view and use the Estimation field.

You can update the Type value by making a POST request to the following endpoint:

/api/issues/{issueID}/fields/{typeFieldID}?fields=id,name,value(id,name)

Request body:

{ "value": { "name": "Task" } }

For more details about this request, refer to the sample.

When you've changed the issue type to Task, you can repeat your initial request and update the Estimation field, which is now shown in the issue.

Last modified: 30 April 2024