4 Replies Latest reply on May 3, 2017 7:20 PM by Peter Love

    Rest API pagination weirdness

    td31580

      Hi All!

       

      I am building a tool that uses the Rest API to read the course details. I am able to register and get an auth token well enough, but whenever I query the course list, it includes a nextPage key. When I follow the nextPage link, I am served the same course that was available on the first page, and yet another nextPage link. This will continue for over a dozen requests before it returns without the next page. Currently I am working around this by just keeping track of all of the courses, then just returning the unique courses, but obviously I am not fond of this solution due to the large number of requests.


      Is there any reason why the courses rest api would be including nextPage links, even though there are no more courses are available?

        • Re: Rest API pagination weirdness
          Peter Love

          What version of Learn are you using?

           

          The behaviour of paging and detecting when you had reached the end changed a bit between versions.

           

          Does you initial call to get the course list contain an offset or limit?

          2 of 2 people found this helpful
            • Re: Rest API pagination weirdness
              td31580

              I am testing against the Developer VM titled bb-learn-9.1-Q4-2016. The System Admin menu shows "Release 3100.0.0-rel.107+401e22b" as the version. Initially I had tried various values in the limit query, but I am not currently setting one, nor am I setting an offset for the first request.

              1 of 1 people found this helpful
                • Re: Rest API pagination weirdness
                  Peter Love

                  There does seem to be some weirdness.

                   

                  I seem to get the last page of courses repeated before getting empty results.

                   

                  The last page of courses I get has an offset that is at the end, so it should be returning empty results, but it returns the last page instead.    The offset has to get to some value beyond the last page before the empty results are returned.

                  1 of 1 people found this helpful