How can this be done via the api?

carlospliego March 30, 2016

This question is in reference to Atlassian Documentation: Flagging an Issue

I would like to be able to update the flag state on an issue via the api. How can this be done?

2 answers

2 votes
Steven F Behnke
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.
March 30, 2016

There is a field called Flagged. It is a checkbox type field. There is a single value by default, Impediment. The field is checked for null status. If the field is null, the issue is not flagged. If the field is not null, the issue is flagged.

 

You would use the REST API for this. Examples are here – https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue.

 

You'll either need to know the field ID (customfield_10000) or you need to to script the discovery of the field by searching the metadata – https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-discovering-meta-data-for-creating-issues.

 

An example of setting a custom field while creating the issue over API – 

curl -D- -u fred:fred -X POST --data {"fields":{"project":{"key": "TEST"}, "summary": "Always do right. This will gratify some people and astonish the REST.", "description": "Creating an issue while setting custom field values", "issuetype":{"name": "Bug"}, "customfield_10000": [{"value": "Impediment"}]}} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
{
    "fields": {
       "project":
       { 
          "key": "TEST"
       },
       "summary": "Always do right. This will gratify some people and astonish the REST.",
       "description": "Creating an issue while setting custom field values",
       "issuetype": {
          "name": "Bug"
       },       
       "customfield_10000": [ {"value": "Impediment" }]       
   }
}
Bill Bill January 26, 2022

This no longer appears to work.  I would post exactly what I'm seeing but this idiotic form won't let me enter json.

Like Matthew DeMartino likes this
0 votes
Nils Kröger May 4, 2023

I spent like 3 hours trying to figure it out and it always gave back "Field 'customfield_10021' cannot be set. It is not on the appropriate screen, or unknown.". To fix it, simply click on Settings Icon -> Issues -> Custom Fields. Search for "Flagged" click on "Screens", Add or remove associated screens" and just add it to all screens. Then it works perfectly.

Suggest an answer

Log in or Sign up to answer