How to get full output of filter execution using powershell script?

Sreejesh Padippura Veettil July 2, 2021

While running url for cloud jira filter getting 110 Jiras. But while calling that service using powershell script(Rest API) getting  only 50 jiras as output.
Is there any way to get all the jiras in issues object?
Please suggest

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2021

Hello @Sreejesh Padippura Veettil ,

Welcome to the Atlassian Community!

If I understand correctly what you are trying to call a REST API endpoint to search for issues from a power-shell script, but this is only returning 50 results instead of the 110 results you get when you run the same query in Jira.

Can you kindly confirm my understanding is correct or provide more details?

 

Now, if my understanding is correct, depending on the REST API endpoint called this can actually be the expected behavior and you simply need to cycle through the results, as mentioned in the Jira Cloud REST API - Pagination documentation:

Pagination

The Jira REST API uses pagination to improve performance. Pagination is enforced for operations that could return a large collection of items. When you make a request to a paginated resource, the response wraps the returned array of values in a JSON object with paging metadata. For example:

Copy
{
    "startAt" : 0,
    "maxResults" : 50,
    "total": 200,
    "isLast": false,
    "values": [
        { /* result 0 */ },
        { /* result 1 */ },
        { /* result 2 */ }
    ]
}
  • startAt is the index of the first item returned in the page.
  • maxResults is the maximum number of items that a page can return. Each operation can have a different limit for the number of items returned, and these limits may change without notice. To find the maximum number of items that an operation could return, set maxResults to a large number—for example, over 1000—and if the returned value of maxResults is less than the requested value, the returned value is the maximum.
  • total is the total number of items contained in all pages. This number may change as the client requests the subsequent pages, therefore the client should always assume that the requested page can be empty. Note that this property is not returned for all operations.
  • isLast indicates whether the page returned is the last one. Note that this property is not returned for all operations.

 

In other words, you will need to run multiple request having different value for startAt until you get all the results.

In your script you can achieve this by doing something like below example:

 

while(isLast!=true) {
   startAt = startAt + maxResult;
}

 

Finally, there is a Feature Request open in our system asking to increase the value for maxResults:

You may want to vote and watch the above feature request so that you will get notified in case of any update. The  feature will be addressed according to the Implementation of New Features Policy

 

I hope this helps.

 

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer