Does the JIRA REST API support querying a list of labels?

岁酱吖の 提交于 2021-02-20 04:42:40

问题


I see the is the ability to get all components of a project by doing

/project/[projectkey]/components

but I don't see any capability or documentation on how to get the list of labels that are available for a project (something like:

/project/[projectkey]/labels

Does the JIRA REST API support querying the list of labels available on a project?


回答1:


Just to clarify, labels (at least the built-in JIRA ones) are global entities so they can be attached to any Issue in any Project.

As to your question - no, there's no public REST endpoint to get/change/add labels to JIRA.




回答2:


Jira Cloud has /rest/api/3/label.

Jira Server provides /rest/api/2/jql/autocompletedata/suggestions?fieldName=labels which is however not paginated and only returns the first few labels (label values can be queried using &fieldValue=X).

However, as hacky workaround you can misuse the API endpoints some Atlassian Jira Gadgets are communicating with. Though this has the following disadvantages:

  • Are internal APIs
  • Atlassian apparently plans to replace Gadgets with Dashboard Items eventually
  • Might change behavior, see e.g. JRASERVER-67446
  • No pagination (?), responses can be huge
  • Responses are designed for Gadgets, therefore contain irrelevant data

Labels Gadget

/rest/gadget/1.0/labels/gadget/project-<PROJECT_ID>/labels
Where <PROJECT_ID> is the numeric ID of the project.

Heat Map Gadget

/rest/gadget/1.0/heatmap/generate?projectOrFilterId=<PROJECT_OR_FILTER>&statType=labels
Where <PROJECT_OR_FILTER> can be either:

  • project-<PROJECT_ID>
  • filter-<FILTER_ID>


来源:https://stackoverflow.com/questions/39443649/does-the-jira-rest-api-support-querying-a-list-of-labels

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