Re^3: Paging with REST::Client?
by bliako (Monsignor) on Jan 13, 2020 at 21:44 UTC
|
just a shot in the dark, the server may be sending data keyed on "address" (10.20.30.40). In order to get to the next 500 results you have to use the last "address" you got from the last results page and send this as "start_addr".
sort of! In the link below, the server returns a reference to send it back to get the next page: perhaps you can figure it out by searching for paging in this page: https://ipam.illinois.edu/wapidoc/additional/sample.html?highlight=paging
| [reply] |
|
Nice guess at the third party app!! Looking at my confusing old code, I don't think the query/search needs to change. You just have to pass in _next_page_id from the previous query in as _page_id in the new query. I'm not 100% on that as I haven't looked at this code in several months and there's a reason I wanted to get away from having to manually do the paging. It really could benefit from an OOP approach, and I was hoping there was a module that already handled it.
| [reply] |
|
| [reply] |
Re^3: Paging with REST::Client?
by 1nickt (Canon) on Jan 13, 2020 at 17:16 UTC
|
| [reply] [d/l] |
|
Sorry, I should have been clear -- that's an example from my old Curl code. REST::Client isn't doing any of the paging.
| [reply] |
|
Umm, right. Rest::Client does not do any paging. You said that it's on the server. So that means that you will have to provide the parameters or headers necessary to Rest::Client in the call it makes, and write a wrapper that collates the results from the various requests.
What does the documentation of the API you are calling say about paging?
The way forward always starts with a minimal test.
| [reply] |
|
|
|
Re^3: Paging with REST::Client?
by Anonymous Monk on Jan 14, 2020 at 01:06 UTC
|
I'm not an expert on RESTful APIs, so I'm not sure what specifically is supplying the functionality, but it's on the server side of things. It's something passed in via the URL. Here's an example URL from some debug output I have lying around:
Hi
;) Have you read what you wrote?
Surely you know exactly the actions you took, cause you say
"passed in via URL"
Well, there you go, the module does accepts URLs
https://metacpan.org/pod/REST::Client#GET-(-$url,-%5B%25$headers%5D-)
So what happened when you did that (pass via url)?
"paging" ain't nothing but a loop (foreach) where you ask for some more
| [reply] |
|
In theory I could pass in the paging parameters and see what REST::Client does with it, but I was hoping it supported it so it could be transparent to me -- i.e. just keep puling in thew data behind the scenes for me. Otherwise, it's back to some ugly code to deal with it. Maybe I can handle it slightly better than my Curl based scripts, but it adds a lot of complexity to the code just to handle something that feels like it should be part of the feature set of the module (e.g. a ->next function, or the abiltiy to tell it to slurp everything in).
The "don't know" part -- I know the server side is handling the paging, but not sure what specifically is handling it (module in the web server, some process the WAPI calls are passed to, etc.).
| [reply] |
|
In theory I could pass in the paging parameters and see what REST::Client does with it, but I was hoping it supported it so it could be transparent to me -- i.e. just keep puling in thew data behind the scenes for me. Otherwise, it's back to some ugly code to deal with it. Maybe I can handle it slightly better than my Curl based scripts, but it adds a lot of complexity to the code just to handle something that feels like it should be part of the feature set of the module (e.g. a ->next function, or the abiltiy to tell it to slurp everything in).
I suggest you read REST to see what it actually is.
Same for REST::Client
The "don't know" part -- I know the server side is handling the paging, but not sure what specifically is handling it (module in the web server, some process the WAPI calls are passed to, etc.). Is that like, I know gas gets gas delivered, but I dont know which refinery or how its delivered exactly?
That is a baffling response to being asked which gas station.
| [reply] |
|