Jira Rest API Pagination

jelle van den broek September 22, 2022

I am now on an internship and need to connect the jira rest api and our website. The connection works and I have already collected the project versions.

the version list is very long. So I want to make sure that you only see 5 versions per page. By that I mean that if there are more than 5 items in the list, it will automatically create a new page with the rest of the list.

I've searched everywhere for an answer, but haven't been able to find anything yet. someone who has been able to find a tutorial or can explain themselves how it works.

btw i work in php.

 

The code i use to get the project versions

        $items = [];

        try {

            $param = [

                'startAt' => 0,

                'maxResults' => 5,

                'orderBy' => '-name',

            ];

            $proj = new ProjectService();

            $items = $proj->getVersionsPagenated('TEST', $param);

            foreach ($items as $v) {

                echo "<hr>";

                var_dump($v->name, $v->self, $v->id, $v->releaseDate);

                echo "<br>";

            }

1 answer

1 vote
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 23, 2022

Hi,

Welcome to the community.

You could try to get all the project version in a list, then take the length of the list and if it's greater that 5 take the 5 first item send them to the first page and create other page for the rest of the list

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events