Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a flag to jira issue via rest api

I would like to be able to add a flag to an issue via the Jira API. I was unable to find any documentation regarding this issue. Does anyone know how this works?

like image 727
Carlos Pliego Avatar asked Mar 24 '16 18:03

Carlos Pliego


2 Answers

I've figured out how to do this, I'm not sure on the version of the API. I made a POST request to:

yourdomain /rest/greenhopper/1.0/xboard/issue/flag/flag.json

And in the body (replace JIRA-ISSUE with your issue key):

{"issueKeys":["JIRA-ISSUE"],"flag":true}

I hope this helps.

like image 51
Xareyo Avatar answered Oct 26 '22 14:10

Xareyo


Here is the best answer I found. https://answers.atlassian.com/questions/38062844/answers/38062897

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/
non-minified data  Expand source
{
"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" }]       
  }
}
like image 35
Carlos Pliego Avatar answered Oct 26 '22 13:10

Carlos Pliego