Cannot set project custom field default values

I'm having problems working out how to set project customfield default values using the new rest api. We setup projects through the API from templates. The templates contain a list of customfields. I want to be able to set the default value for 2 of the fields before any issues are created so they will automatically inherit those default values.

I think I have the Post URL correct but I'm not sure about the body.  I've tried a number of different body values and now I am receiving a java.lang.InstantiationException" error.  I'm using the following POST URL
https://xxxx.myjetbrains.com/youtrack/api/admin/projects/nn-nnn/customFields/mm-mmmm
where nn-nnn and mm-mmmm are the project and custom field ids I used to GET the data.  The body I am using is the following:
{    "field": {
        "id": "yy-yy"
    },
    "defaultValues": [ {
        "name": "my default value",
        "id": "zz-zzz"
    } ]
}
where yy-yy and zz-zzz are the id's returned in the GET.

I just can't seem to get the correct body content for the POST to work

0
1 comment

Hello Nick,

You need to specify the value's and field's type in the request body as well, the endpoint and the request body should look like this:

POST https://example.myjetbrains.com/youtrack/api/admin/projects/{project_id}/customFields/{field_id}

{ "defaultValues": [ { "id": "{value_id}", "$type": "EnumBundleElement" } ], "$type": "EnumProjectCustomField" }
0

Please sign in to leave a comment.