Hi,
I think we need to have a consistent way of knowing when we have reached the end of collections gets.
Perhaps, no nextPage returned with the last page, and/or something like a 404 (Not Found) if you request a page that does not exist. And/or some way of knowing the total number of objects so you could work it out yourself.
It seems to vary with object. For DSKs, the nextPage does disappear, and I get a 400. For users, the nextPage disappears and no users are returned. But for courses, the only way I see is to keep going until you get a 500 Internal Server Error.
For example, if I have four courses and do a get courses with offset 0 and limit 2 I get back:
'nextPage' => '/learn/api/public/v1/courses?fields=courseId%2CexternalId&limit=2&offset=2'
All okay, so get courses with offset 2 and limit 2, get back:
'nextPage' => '/learn/api/public/v1/courses?fields=courseId%2CexternalId&limit=2&offset=4'
Now, get courses with offset 4 and limit 2, and you get a 500 Internal Server Error.
Is this the same behaviour for anyone else?
Cheers,
Peter
Yes. I saw this when I tested getting the courses from an empty developer VM. It returns 500 just as well. I checked in the log file, it says NullPointerException. It seems whenever the method can not retrieve any course, it returns null instead of an empty list and leaves that uncaught.
I say it's a bug.