cancel
Showing results for 
Search instead for 
Did you mean: 

Order of reponses when using pagination with http client

janwyl
New Contributor

Hello!

I need to fetch a large number of values from an API and retrieve them sorted. The API allows me to specify that the results are sortef and the pagination appears to be working fine. However, I have noticed that I sometimes get errors downstream because the results are in fact not sorted correctly.

I have not fully analyzed the problem but one possible theory I have is that the http client does not wait for a reply before sending the request for the next page. This would mean that a page of results could be received out of order.

Can anyone confirm whether the paginated responses to the http client are guaranteed to be in the same order as the requests?

Thanks very much!

6 REPLIES 6

The error I had was this :

janwyl_0-1724245859595.png

importId is the value I have fetched from the API (in ascending order) and I am joining with other data using inner join and ascending sort order. I interpret this to mean that the error was thrown because the importId of 3210448-USM18 came before 3210448-NYR6 in the join.

I have just twice fetched only the importIds from the API (without doing the join) and both times 3210448-NYR6 came before 3210448-USM18.

In addition, every single value of importId takes the form of 7 numbers followed by a hyphen followed by some other combination of letters and characters. My understanding of sort collation may not be sufficiently advanced so apologies if I'm on the wrong track - given that format I'm not sure how sort collation could have an impact. Even if one collation ignores the hyphen it's the same for every single value?

Thanks again for your thoughts !

janwyl
New Contributor

I've also been trying to check my union theory by passing the provided offset value to the results. If that offset value is not in increasing order then that would prove the union theory, but so far it's come back fine both times