Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to view a list of assignees for a given jira ticket using Jira API?

Maz_Mahari
August 11, 2022

With or without JQL. is it possible to get some result that lists all the assignees for a given srpint. 

Something like this 

{

  "projectName": "something",

  "dateCreated": "2019-01-24T15:43:44.000-0600",

  "summary": "Verify business is OK with update",

  "description": "This has been rolled out into production",

  "assignee": ["john doe", "Maz Doe"], // I need this to be an array
  "status": "Done",

  "statusColor": "label-success",

  "estimated": 0,

  "remaining": 0,

  "logged": 0,

  "estimateTimeDifference": 0,

  "hasEstimateChanged": false,

  "labels": "",

  "components": "something something",

  "epic": null

}

2 answers

1 accepted

1 vote
Answer accepted
Maz_Mahari
August 17, 2022

Using the changelog parameter to the issues JQL endpoint and with this logic, I got all the assignees for a given issue. 

 

  public listIssueAssignees(issue: Issue): string {

    const histories = issue.changelog ? issue.changelog.histories : [];

    const assignees: string[] = [];

    if (histories) {

      histories.forEach((history: any) => {

        history.items.forEach(

          (item: { field: string; fromString: string; toString: string }) => {

            if (item.field === 'assignee') {

              assignees.push(item.fromString);

              assignees.push(item.toString);

            }

          },

          this

        );

      }, this);

    }

    return [...new Set(assignees)].filter(v => v != null).join(', ');

  }
1 vote
Trudy Claspill
Community Champion
August 11, 2022

Hello @Maz_Mahari 

Welcome to the community.

A Jira issue can have only one Assignee at a time. Are you trying to extract the history to find out if the Assignee has been changed such that different people were assigned to the issue at different times?

Maz_Mahari
August 11, 2022

Yes, that's right. I'd love to be able to view a history of past assignees for a given issues

Trudy Claspill
Community Champion
August 11, 2022

Have you looked at the Jira REST API? The endpoint for getting an issue can return the issue history if you use the expand parameter. You would have to parse through the output to get the entries concerning Assignee, and build your own output array.

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-get

Maz_Mahari
August 12, 2022

Do you mean pair expand with changelog. Because that wouldn't work?

Trudy Claspill
Community Champion
August 12, 2022

Yes, that is what I meant. I did not actually test it. I suggested it based on the documentation.

It what way does it not work?

Suggest an answer

Log in or Sign up to answer