---
schema: rendered-html/v1
title: "500 Server Error When Adding a Field to a Project | Developer Portal for YouTrack and Hub Documentation"
source_url: https://www.jetbrains.com/help/youtrack/devportal/api-troubleshoot-custom-field-prototype.html
generated_at: 2026-06-11T15:00:23.053197+00:00
---

Feedback

Thanks for your feedback!

Was this page helpful?

YesNo

Developer Portal for YouTrack and Hub

- Developer Portal
- Apps
- MCP Tools
- YouTrack Workflows
- YouTrack Import Scripts
- YouTrack Form API
- YouTrack REST API
- Get Started with REST API
- REST API Reference
- [REST API Use Cases](jetbrains__com__help__youtrack__devportal__api-use-cases.md)
- [REST API Troubleshooting](jetbrains__com__help__youtrack__devportal__api-troubleshooting.md)
- [400 Bad Request When Adding a Custom Field Value to a Set](jetbrains__com__help__youtrack__devportal__api-troubleshoot-incorrect-request-url.md)
- [400 Bad Request When Creating an Issue Without Required Field Value](jetbrains__com__help__youtrack__devportal__api-troubleshoot-missing-type.md)
- [400 Bad Request When Updating a Conditional Field](jetbrains__com__help__youtrack__devportal__api-troubleshoot-updating-conditional-field.md)
- [500 Server Error When Updating a Custom Field](jetbrains__com__help__youtrack__devportal__api-troubleshoot-incorrect-field-type.md)
- [500 Server Error When Adding a Field to a Project](api-troubleshoot-custom-field-prototype.html)
- Color Indices List
- Hub REST API

1. YouTrack REST API
2. [REST API Troubleshooting](jetbrains__com__help__youtrack__devportal__api-troubleshooting.md)
3. [500 Server Error When Adding a Field to a Project](#0)

# 500 Server Error When Adding a Field to a Project﻿

Last modified: 07 May 2026

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 jetbrains.charisma.customfields.rest.CustomFieldMegaProxy
    cannot be cast to class jetbrains.charisma.customfields.rest.ProjectCustomField
    (jetbrains.charisma.customfields.rest.CustomFieldMegaProxy and
    jetbrains.charisma.customfields.rest.ProjectCustomField 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.

| Attribute | Value |
| --- | --- |
| Request method | POST |
| Endpoint | `/api/admin/projects/projectID/customFields` |
| Request body | ``` {   "name": "Last message related emails",   "id": "46-21",   "$type": "CustomField" } ``` |
| HTTP response code | 500 |

## Troubleshooting﻿

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

### Cause﻿

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`.

### Solution﻿

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`.

- [500 Server Error When Adding a Field to a Project](/help/youtrack/devportal/api-troubleshoot-custom-field-prototype.html)
- [Error Message](/help/youtrack/devportal/api-troubleshoot-custom-field-prototype.html#error-message)
- [Request Details](/help/youtrack/devportal/api-troubleshoot-custom-field-prototype.html#request-details)
- [Troubleshooting](/help/youtrack/devportal/api-troubleshoot-custom-field-prototype.html#troubleshooting)

[500 Server Error When Updating a Custom Field](jetbrains__com__help__youtrack__devportal__api-troubleshoot-incorrect-field-type.md)Color Indices List

- Privacy & Security
- Terms Of Use
- Trademarks
- Legal

Copyright © 2000–2026 JetBrains s.r.o.
