Example for creating a custom field and assigning it to a project

I want to create a new project, create custom fields and assign the fields to the project using the REST API. 

- Creating the project works perfectly.

For creating custom fields I found this documentation: https://www.jetbrains.com/help/youtrack/devportal/resource-api-admin-customFieldSettings-customFields.html#create-CustomField-method

Using the code here I'm able to create a custom field; BUT the field is not visible in the UI. With a GET request to the API the new field gets returned (so it must exist).

Can you please provide a full example of:

- Creating a field with values

- Assigning it to a project

 

Thank you very much.

 

0
1 comment

Hi Dave! Unfortunately, we don't have a step-by-step guide with sample requests, but here is how it could be achieved overall:

1. Create an enum field. This part has been done on your side already. The response should contain the ID of the created field.

2. Next, you probably want this field to have a default set of values. Assuming the set does not exist yet, you'll need to make two requests: a POST to create one (/api/admin/customFieldSettings/bundles/enum) and a PUT to update the field to provide a default set of values (/api/admin/customFieldSettings/customFields/96-317/fieldDefaults/bundle).

3. Now you can add it as a project custom field, which is covered in Add a New ProjectCustomField. You'll need to provide the ID of your original field (also known as the CustomField prototype).

It may help to go through these steps in the UI and observe the requests being made in the Network tab of your browser developer tools. The same endpoints should be available to use through REST API.

0

Please sign in to leave a comment.