Set project customfield defaultvalue

We use several custom fields in our projects.  We are using the new REST API to create projects and want to be able to set the defaultvalue for 2 customfields before any issues are created so they are inherited.  We know how to do this using the UI but cannot work out how to do it using the REST API.

I can get the bundle values using the

GET https://company.myjetbrains.com/youtrack/api/admin/projects/{projectID}/customFields/{customFieldID}?fields=id,name,defaultValues(name), aliases,bundle(id,values(id,name)),emptyFieldText,field(name,id),project(id,name)

I've tried various methods fo the POST URL and body but so far with no success. I'm trying to use

POST https://company.myjetbrains.com/youtrack/api/admin/projects/78-715/customFields/79-7124?fields=id,name,defaultValues(name)

with the body

{
    "customFields": [
        {
            "defaultValues": [
                {
                    "name": "value to be set"
                }
            ],
            "field": {
                "id": "{fieldID}"
            },
            "id": "{customFieldID}"
        }
    ]
}
 
It's returning success but the default value is not changing.
 
Please can someone point me at what I am doing wrong!
0
1 comment

Hello Nick,

Please try the following request:

PUT /api/admin/projects/%PROJECT_ID%/fields/%FIELD_ID%/defaultValues
0

Please sign in to leave a comment.