0

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.

Cena
  • 3,316
  • 2
  • 17
  • 34
aks
  • 13
  • 6
  • Can you display the exception detail, mostly the inner exception. – vernou Oct 28 '20 at 10:12
  • ` This exception was originally thrown at this call stack: [External Code] Inner Exception 1:AggregateException: One or more errors occurred Inner Exception 2:JsonSerializationException: Error converting value {null} to type 'System.Boolean'. Path '[9].packages_enabled', line 1, position 30094. Inner Exception 3:InvalidCastException: Null object cannot be converted to a value type` – aks Oct 28 '20 at 11:07
  • See this `JsonSerializationException: Error converting value {null} to type 'System.Boolean'. Path '[9].packages_enabled'`. In the DTO `Projects`, the property `packages_enable`need be of type `bool?`. – vernou Oct 28 '20 at 11:37
  • Yuuup that was it. Now, I found another similar errors in DTO Projects. It's all because I used "Paste special > Paste JSON as Classes" Tnx a lot – aks Oct 28 '20 at 11:54

1 Answers1

0

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

aks
  • 13
  • 6