API is not able to modify value for issue related custom field

s sushil Tade November 29, 2020

I have a issue created. The issue has a custom property "Ignore for Release" the value is checkbox. 

Now I want to check and uncheck the value for this property using REST API. 

What I tried:

1- Method GET. I have retrieved all the fields using https://domain.com/rest/api/2/field/ 

2- Method PUT. https://domain.com/rest/api/2/issue/{issueId}/properties/{fieldId}

Body:

[{ "id" : 12840}]

API returns 201 but still I don't see any changes for my issue. The check box should be checked when I hit API mentioned in bullet 2. 

Not sure what I am doing wrong :(

1 answer

1 accepted

0 votes
Answer accepted
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 30, 2020

Hi @s sushil Tade 

I don't update checkboxes, but to update the Description field, I use a PUT method with the following call

/rest/api/2/issue/ABC-123

and pass in JSON like this

{
  "update":

  {
    "description": [
    {
      "set": "new text goes here"
    } ]
  }
}
 
s sushil Tade November 30, 2020

Thanks, Description part will work but I have concern with added custom field. Do you have any idea how to update value for checkbox?

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 30, 2020

Hi @s sushil Tade 

Yes you can do customfields as well. I've managed to set a checkbox on my system passing in this JSON

{
  "update":

  {
    "customfield_14572":

    [
      {
        "set":

        [
          {
            "value": "Yes"
          }
        ]
      }
    ]
  }
}
s sushil Tade November 30, 2020

@Warren It's working. You made my day!. Thank you. Also I have question how to reset the value back (how to uncheck?).  

Please send me the link from did you find above payload. I am able to find the field Id. but I was using this API https://domain.com/rest/api/2/issue/{issueId}/properties/{fieldId}

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 30, 2020

Hi @s sushil Tade 

I'm glad it worked for you as well.

To unset it, replace "Yes"  with null - note that null doesn't use quote marks.

To find the field ID, go to Settings, Issues, Custom Fields, then on the custom field you want, click the 3 dots on the right of that row, select Edit and look at the URL

 

Screenshot_1.jpg

s sushil Tade November 30, 2020

Thanks!. You are Awesome. I never thought of null

Also thanks for helping about how to find field ID. 

Suggest an answer

Log in or Sign up to answer