Search code examples
c#async-awaitgetgitlab-api

c# Gitlab get api pagination


I wrote a method which calls to Gitlab API but I cannot get more than 47 projects.
When I call this method like this:

List<Projects> projects = GetProject("/api/v4/projects?per_page=47").Result; 
List<Projects> projects = GetProject("/api/v4/projects?per_page=20&page=1").Result; 
List<Projects> projects = GetProject("/api/v4/projects?per_page=20&page=2").Result; 

it work fines, but this:

List<Projects> projects = GetProject("/api/v4/projects?per_page=48").Result; 
List<Projects> projects = GetProject("/api/v4/projects?per_page=20&page=3").Result; 
List<Projects> projects = GetProject("/api/v4/projects?per_page=10&page=5").Result; 

It doesn't work and I get System.AggregateException on RunAsync().Wait();.. Every time when I try to get more than 47. I checked in RESTer and when I call GET like this:

https://local/api/v4/projects?per_page=48

It works and I get an answer that there are 1474 projects,31 pages:

enter image description here

Please help.


Solution

  • I resolved my pagination problem in this post: stackoverflow.com/a/64855501/10522472