How do I get a list of labels for a Jira server with C#?
I can get a list of projects with
jira.Projects.GetProjectsAsync();
a list of components for a project with:
jira.Components.GetComponentsAsync(project);
Is there an API to get a list of labels? Per project or global?
As per the version 3 API documentation there is a call to get the global labels.
Hope this helps
Thanks, that got me a global list of labels. Any way to get a list of labels per project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's known as Scope Creep - your question said either per project or global, I give you global but you actually want per project ;-)
Seriously, no I can't see a way to limit it to a project, the only parameters it takes is startAt and maxResults
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Pete Goodwin ,
You can use the REST API endpoint for GET /rest/api/3/label as the first step. But again as @Warren noted, this just gives you back the labels across all projects.
However, once you can see the names of these labels, you can put these into a JQL search via REST for each label name to the endpoint GET /rest/api/2/search.
I do not have a working example in C# but in theory, as an example, a call formatted something like the following, where this will return all the issues that use a specific label and then order the results by their project. From there you could then take that data to match out the project value per issue or the issue key of the issues returned to see which projects are using this:
GET /rest/api/2/search?jql='labels in (label1,label2,label3,.....etc) order by project desc'
OR the following which would isolate to the specified project, and return any issues with labels in use from your list of all labels, which could then be grouped to show unique labels for your list per project in yor script.
GET /rest/api/2/search?jql='labels in (label1,label2,label3,.....etc) AND project = EXE'
Hope this helps
Regards,
Earl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've discovered there are 3000+ labels globally, so can that work with labels in (x, y, z...)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Pete Goodwin ,
Long URL's can hit memory issues in the browser but I do not believe you would run into any limitation in the API and would allow for much longer input strings. The only downside is that manual input would be unmanageable as the labels can be added in ad-hoc so constant watching for updates would be needed. Going this route I would suggest looking into a method to script the input values into the second query from the first.
Another option for this would be a front-end method and use the Labels Gadget. Drop the labels gadget onto a dashboard, set to project and labels and it will populate a list of labels used in that particular project. Unfortunately in this approach, the data is returned in the gadget is using a client-side javascript to process the information in the browser so there is not an option to automate pulling the data out of the gadget via the API, but it would dramatically reduce the footprint by isolating the lists to the specified projects and reduce overhead on the input manual approach.
Regards,
Earl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.