Reputation: 1194
I need to get all the pull request IDs using REST API. I am using the below api to get.
https://stash.net/rest/api/1.0/projects/{}/repos/{}/pull-requests?at=refs/heads/release-18&state=ALL&order=OLDEST&withAttributes=false&withProperties=true&limit=1000
In the response it has only size 100 even i am setting limit as 1000
{
"size": 100,
"limit": 100,
"isLastPage": false,
"values": [],
"start": 0,
"nextPageStart": 100
}
Is there any way to get the pull requests ?
Upvotes: 1
Views: 1379
Reputation: 5187
There's nothing wrong with your REST API call. The endpoint you're calling has a default of 25 results with an upper limit of no more than 100. Any limit
value over 100 will return the maximum of 100 results.
There's good reason for this: it's protecting the application from loading too many results into memory at once. Stash / Bitbucket Server typically uses a fairly small heap size, as the heavy lifting is done by git and you don't want the JVM using up memory that git needs. 99.9% of the time the correct approach here is to use the paged API the way it wants to be used: one page at a time. It should be relatively easy to page through the results to get all the data you need, and I can update this answer with a Python example of paging if you’re stuck there.
If you really want to change this limit, you can do do so via Bitbucket Server config properties by setting page.max.pullrequests=1000
in $BITBUCKET_HOME/shared/bitbucket.properties and restarting the application. I wouldn't suggest it though, you may be setting yourself up for OutOfMemory errors in your JVM if you're not careful.
Full disclosure, I work for Atlassian.
Upvotes: 2