Search code examples
paginationjirajql

How to do Jira JQL pagination


I'm getting a list of tickets from Jira through their API. But I can't get the startAt and maxResults parameters to work.

Php code:

$command  = "curl -u [email protected]:$apiToken -X GET -H \"Content-Type: application/json\" https://xyz.atlassian.net/rest/api/2/search?jql=project+=+%22SC%22&startAt=2&maxResults=40";

$json = exec($command, $return_var);

No matter what I do, I always get the default 50 results of the first page.


Solution

  • There's no problem about Jira REST API, curl just can't get url params. Try cover url with a single quote, it should resolve the case.

    $command  = "curl -u [email protected]:$apiToken -X GET -H \"Content-Type: application/json\" 'https://xyz.atlassian.net/rest/api/2/search?jql=project+=+%22SC%22&startAt=2&maxResults=40'";
    
    $json = exec($command, $return_var);