StoneThrow
StoneThrow

Reputation: 6295

How to get many issues with Jira REST API?

New to REST API, and struggling a little.

I learned recently from here and here that I can receive a JSON describing an issue by calling a REST API of the form <JIRA_BASE_URL>/rest/api/2/issue/{issueIdOrKey}, e.g.:

curl -s -X GET -u super_user:super_password https://jira.server.com/rest/api/2/issue/TEST-12

Is there a way I can query many issues at once if I have a list of issue-ids, e.g. ["TEST-12", "TEST-13", "TEST-14"]?

I'm specifically interested in getting the summary field of each issue in my list of issue-ids. I.e. I'm trying to create a map of [issue-id:summary]. I currently do this by invoking the above curl command in a loop for each issue-id in my list. But I observe that this takes a long time, and I wonder if performance might be improved if there's a way to do a "bulk get" -- if such a feature exists.

Upvotes: 6

Views: 6096

Answers (1)

Adil B
Adil B

Reputation: 16866

Give the JQL Search API endpoint a try:

https://jira-url/rest/api/latest/search?fields=summary&jql=key%20in%20(TEST-12,%20TEST-13)

The fields parameter limits the fields returned, and the jql parameter lists out an array of the issue keys you'd like to retrieve.

The response looks like this:

{
    ...
    "startAt": 0,
    "maxResults": 50,
    "total": 2,
    "issues": [
        {
            ...
            "key": "TEST-12",
            "fields": {
                "summary": "TEST-12 Summary"
            }
        },
        {
            ...
            "key": "TEST-13",
            "fields": {
                "summary": "TEST-13 Summary"
            }
        }
    ]
}

Upvotes: 5

Related Questions