I'm using ScriptErrorDetails in my script and searches for '404' to stop loading. You should be able to do something similar.
SET ErrorMode = 0;
Let vContinueLoad = SubStringCount('$(ScriptErrorDetails)','206');
exit do when vContinueLoad <> 1;
Something like that might do the trick
I like to use it in the 'WITH CONNECTION' part of the script
I already tried the errormode, but there is no error coming from the 'WITH CONNECTION'
So ScriptErrorDetails stays <NULL>
When I get a 206 means there is more data available from the REST API so I would like to take the next 100 (page_size).