Developer Portal for YouTrack and Hub Help

500 Server Error When Adding a Field to a Project

This article examines an error that might occur when you add a custom field to a project using YouTrack REST API. You might get this error when you reference a field prototype instead of a project custom field in a POST request.

Error Message

{ "error": "server_error", "error_description": "class cannot be cast to class ( and are in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @494dd782)" }

Request Details

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



Request method




Request body

{ "name": "Last message related emails", "id": "46-21", "$type": "CustomField" }

HTTP response code



Here are some possible causes and suggestions on how to overcome the error and add a field to the project.


The ID of the custom field that you're using in the body of the POST request is incorrect. It references the prototype of a custom field instead of the project custom field.

In your request, you are adding a prototype of a custom field to a project. Projects, however, don't contain direct references to the base entity. Instead, they contain references to instance of a CustomField entity, which is ProjectCustomField.


The first step to a valid POST request is to figure out which entity type this resource expects. In the case of the /api/admin/projects/projectID/customFields resource, the expected entity type is ProjectCustomField. You must pass an object of the corresponding type in the request body.

Each project custom field contains the settings of its custom field prototype (an object of the CustomField type). These settings are stored in the field attribute of the ProjectCustomField entity.

When you received the error, you tried passing an object of the CustomField type in the request body. Let's reuse this object in an attribute of a ProjectCustomField entity.

The final request body would look like this:

{ "field": { "name": "Last message related emails", "id": "46-21", "$type": "CustomField" }, "$type": "ProjectCustomField" }

Note that you still need to pass the correct $type of each object. The type of the main object is ProjectCustomField, and the type of the custom field prototype inside it is CustomField.

Last modified: 19 June 2024