Hi Team,
how to get list of all projects, project name and project category name in Jira Data Center
or at least omit pagination on All project types - All categories page
Hi @Chamdarig Dall
In tests, the category shows in the endpoint: /api/2/project
You can use an test script in postman to retrieve all information in a table, the output looks like this:
Here the test script below:
const template = `<style type="text/css"> .tftable {font-size:14px;color:#333333;width:100%;border-width: 1px;border-color: #87ceeb;border-collapse: collapse;} .tftable th {font-size:18px;background-color:#87ceeb;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;text-align:left;} .tftable tr {background-color:#ffffff;} .tftable td {font-size:14px;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;} .tftable tr:hover {background-color:#e0ffff;}</style><table class="tftable"> <thead> <tr> <th>Project ID</th> <th>Project Name</th> <th>Project Category</th> <th>Project Type</th> </tr> </thead> <tbody> {{#each table}} <tr> <td>{{this.id}}</td> <td>{{this.name}}</td> <td>{{this.category}}</td> <td>{{this.type}}</td> </tr> {{/each}} </tbody></table>`;const body = pm.response.json(); // Jira API responseif (!Array.isArray(body)) { console.error("Unexpected response format. Expected an array."); pm.visualizer.set(`<h3 style="color:red;">Error: Unexpected response format</h3>`);} else { const table = body.map(project => ({ id: project.id, name: project.name, category: project.projectCategory ? project.projectCategory.name : "No Category", type: project.projectTypeKey || "Unknown" })); // Set the visualizer with formatted data pm.visualizer.set(template, { table });}
/project/type returns just types of projects in jira, which is irrelevant.
/project is missing category that's why I asked this question
------------------------------------
Nikola Perisic mentioned you in
Get list of all projects, project name and category name
Hi Chamdarig Dall
Project types API that can be retrieved - /api/2/project/type
Getting all visible projects API as well - /api/2/project
More APIs could be found here: https://developer.atlassian.com/server/jira/platform/rest/v10002/api-group-project/#api-group-project
This question has been answered perfectly for most part by @M Amine and @Fabio Racobaldo _Catworkx_ in this forum. As you're on datacenter (as I am), you should be fine with the sql query. I built upon their foundation this query, which works fine for me.
use YOURJIRADBselect p.* , pc.cname as CategoryName from nodeassociation na inner join project p on (p.ID = na.SOURCE_NODE_ID) inner join projectcategory pc on (pc.ID = na.SINK_NODE_ID)
where na.ASSOCIATION_TYPE='ProjectCategory' and na.SOURCE_NODE_ENTITY='Project'
A big thank you to my peers, who opened my eyes regarding the nodeassociation table.Link: Jira-questions/SQL-query-for-Project-name-category-and-workflow/qaq-p/775264
Kind regards,
Dick
Just for Jira Cloud. I need this for DC
This API call and script is for JIRA DC
best regards.
Endpoint is the same but the results are different. I see it in my browser now and that's why I asked this question
It looks like you're new here. Sign in or register to get started.