How to add a flag to jira issue via rest api

可紊 提交于 2020-02-03 05:47:49

问题


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?


回答1:


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.




回答2:


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" }]       
  }
}



回答3:


As mentioned here, "Flagged" is a checkbox custom field that accepts a single value "Impediment".

You should be able to set it using the JIRA REST API just like any other custom field. Maybe the examples here will help.

You can also set custom field values using the JIRA Java API.



来源:https://stackoverflow.com/questions/36207635/how-to-add-a-flag-to-jira-issue-via-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!