Updating Issue Custom Fields

Based on the direction in JetBrains' documentation, I have been trying to set values to custom fields using a POST statement. The documentation I have been following is here: https://www.jetbrains.com/help/youtrack/standalone/api-how-to-update-custom-fields-values.html?_ga=2.40492138.997269667.1591110939-318795090.1586797977
 
I used a GET statement to obtain a list of custom fields associated with the project:

curl -X GET \
-H 'Accept: application/json' \
-H 'Authorization: Bearer perm: XXX' \
-H 'Content-Type: application/json'
 
From this statement, I received the following information:
 
[
{
"field": {
"name": "Subsystem",
"id": "66-0",
"$type": "jetbrains.charisma.customfields.rest.CustomField"
},
"id": "91-77",
"$type": "jetbrains.charisma.customfields.complex.ownedField.OwnedProjectCustomField"
},
{
"field": {
"name": "Priority",
"id": "66-1",
"$type": "jetbrains.charisma.customfields.rest.CustomField"
},
"id": "91-78",
"$type": "jetbrains.charisma.customfields.complex.enumeration.EnumProjectCustomField"
},
{
"field": {
"name": "State",
"id": "66-3",
"$type": "jetbrains.charisma.customfields.rest.CustomField"
},
"id": "91-80",
"$type": "jetbrains.charisma.customfields.complex.state.StateProjectCustomField"
},
{
"field": {
"name": "ArtworkStatus",
"id": "66-46",
"$type": "jetbrains.charisma.customfields.rest.CustomField"
},
"id": "91-99",
"$type": "jetbrains.charisma.customfields.complex.enumeration.EnumProjectCustomField"
},
{
"field": {
"name": "ArtworkLevel",
"id": "66-47",
"$type": "jetbrains.charisma.customfields.rest.CustomField"
},
"id": "91-100",
"$type": "jetbrains.charisma.customfields.complex.enumeration.EnumProjectCustomField"
},
{
"field": {
"name": "Assignee",
"id": "66-4",
"$type": "jetbrains.charisma.customfields.rest.CustomField"
},
"id": "93-10",
"$type": "jetbrains.charisma.customfields.complex.user.UserProjectCustomField"
},
{
"field": {
"name": "jobid",
"id": "66-45",
"$type": "jetbrains.charisma.customfields.rest.CustomField"
},
"id": "114-16",
"$type": "jetbrains.charisma.customfields.simple.common.SimpleProjectCustomField"
}
]
 
The custom field I want to change is the "name":"jobid"/"id":"114-16". I created the following POST statement to do this:
 

curl -X POST \

'https://youtrack.allpack.local/api/issues/APE-102?fields=summary,description,comments,fields(id,name,value)' \

-H 'Accept: application/json' \

-H 'Authorization: Bearer perm:Z2lic29u.QUVfYWNjZXNz.rWPAtEfPu36EPZftf3ZeLDQcGLkwMd' \

-H 'Content-Type: application/json' \

-d '{"fields":{"id":"114-16","$type":"SimpleIssueCustomField","value":"1234"}}'

 

I don't get an error and the field does not update with the expected value. Please help me understand what I need to do differently to update this custom field.

 
 
1
8 comments
Official comment

Hello Michael, I'm very sorry for the delayed reply.

Do you want to change the value of the `jobid` custom field in that particular issue (APE-102), is that correct?

What is the type of the `jobid` custom field?

If it's an integer/float, then you should assign the value directly without quotes:

{
"customFields": [
{
"value": 1234,
"id": "114-16",
"$type": "SimpleIssueCustomField"
}
]
}
 
Note that the correct name of the attribute is 'customFields', not just 'fields'.
Please let me know if that helps.

I have adjusted the POST statement as follows and do not get a better response:

curl -X POST \

'https://youtrack.allpack.local/api/issues/APE-102?fields=summary,description,comments,fields(id,name,value)' \

-H 'Accept: application/json' \

-H 'Authorization: Bearer perm:XXXX' \

-H 'Content-Type: application/json' \

-d '{"fields":{"name":"jobid","$type":"SimpleIssueCustomField","value":"1234"}}'

The server returns the following response:

{
"summary": "This changed",
"comments": [
{
"$type": "jetbrains.charisma.persistent.IssueComment"
}
],
"description": "Issue changes",
"fields": [
{
"value": null,
"id": "114-16",
"$type": "jetbrains.charisma.customfields.simple.common.SimpleIssueCustomField"
},
{
"value": {
"$type": "jetbrains.charisma.customfields.complex.enumeration.EnumBundleElement"
},
"id": "91-100",
"$type": "jetbrains.charisma.customfields.complex.enumeration.SingleEnumIssueCustomField"
},
{
"value": {
"$type": "jetbrains.charisma.customfields.complex.enumeration.EnumBundleElement"
},
"id": "91-99",
"$type": "jetbrains.charisma.customfields.complex.enumeration.SingleEnumIssueCustomField"
},
{
"value": {
"$type": "jetbrains.charisma.customfields.complex.enumeration.EnumBundleElement"
},
"id": "91-78",
"$type": "jetbrains.charisma.customfields.complex.enumeration.SingleEnumIssueCustomField"
},
{
"value": {
"$type": "jetbrains.charisma.customfields.complex.state.StateBundleElement"
},
"id": "91-80",
"$type": "jetbrains.charisma.customfields.complex.state.StateIssueCustomField"
},
{
"value": null,
"id": "93-10",
"$type": "jetbrains.charisma.customfields.complex.user.SingleUserIssueCustomField"
},
{
"value": null,
"id": "91-77",
"$type": "jetbrains.charisma.customfields.complex.ownedField.SingleOwnedIssueCustomField"
}
],
"$type": "jetbrains.charisma.persistent.Issue"
}

0

I have continued to work on this issue but haven't found a solution.

0

Basically, I copied your suggested code submitting the following:

{"customFields":[{"value":1234, "id":"114-16", "$type":"SimpleIssueCustomField"}]}

The response was the following:

{

"fields": [
{
"value": null,
"id": "114-16",
"$type": "jetbrains.charisma.customfields.simple.common.SimpleIssueCustomField"
}

}

The value is not updating with this process.

0

Hi Michael, which YouTrack version are you using? Are you willing to upgrade your installation if your license allows updates?

What are the settings of the `jobid` custom field, could you please share a screenshot?

 

0

We are currently running 2018.3. Yes, we are willing to upgrade if the license allows it. Here is a screenshot of the jobid settings:

0

Michael, I'm sorry for the late response.

I believe the problem lies in the $type names and the YouTrack version you're using. In the older versions of YouTrack (2018.3 and older), the $type names were longer, so they were shortened in the later versions. See the "SimpleIssueCustomField" in my examples and the "jetbrains.charisma.customfields.simple.common.SimpleIssueCustomField" in yours.

Also, the "fields" attribute" was renamed to "customFields".

There are two options:

1) You can use the longer $type name, i.e., use this for the body: 

{"fields":[{"value":1234, "id":"114-16", "$type":"jetbrains.charisma.customfields.simple.common.SimpleIssueCustomField"}]}

2) You can upgrade your YouTrack to version 2019.x (and then to the 2020.x if you wish, but that's not necessary for your goals) and use the examples I've provided earlier.

 

I hope this helps, please let me know how it goes.

0

Please sign in to leave a comment.