@aiuex79_aiuex79 Not an exact example, but the script included in this post walks through paging results with the InsightVM console API.
Looking at your examples, I see one that is using index as the parameter for the page where it should be page specifically for the console api: InsightVM API (v3). For example, /resources?page=2&size=10 would be how you pull the next 10 results from page 2.
The documentation within the /api/3/reports sections has this… Looks like what you posted. The link I posted in the overview uses the “index” example. Neither code sample is helpful…most likely my newness to the API. I want to use this paging to cleanup old reports.
Paging
Pagination is supported on certain collection resources using a combination of two query parameters, page and size. As these are control parameters, they are prefixed with the underscore character. The page parameter dictates the zero-based index of the page to retrieve, and the size indicates the size of the page. For example, /resources?page=2&size=10 will return page 3, with 10 records per page, giving results 21-30. The maximum page size for a request is 500.
Requests that return multiple items can be paginated. When a response is paginated, it will contain a metadata section describing the current page and a data section containing the response data.
Size - The number of items to return per page. NOTE: The returned size may be smaller than the requested size in order to maintain API performance. Always check the metadata.size parameter in the response.
Sort - The key,order pairs to sort by, separated by commas. The key is one of the supported sort keys for a given API. Order is one of ASC, for ascending, or DESC, for descending. Multiple sort keys can be provided by specifying multiple key,order pairs. Please note that this may not be supported by some APIs. You can verify this from your product’s API documentation.
One unfortunate thing at the moment between products is that InsightIDR uses index and InsightVM console api uses page. So just keep that in mind. That example should be a decent starting place - just needs modified for your specific resource/needs. The full script is at the bottom of the initial post and you can expand it to copy/paste it somewhere to get started.
As I loop through increasing the page count from 0, 1, 2, 3 but when I look in the metadata…Shows 0, 0, 2, 3. The first loop works, i get a 500 error when trying the second and other loops. I looked in the logs and can’t determine what the 500 error is. Looks like a null…
@aiuex79_aiuex79 I’m not aware of any API examples maintained anywhere other than the posts here. There are several around running reports, asset searches, etc with full scripts to base things off of.
If you are paging and getting a 500, it’s very possible there is an exception not properly being handled and it is something our VM engineering team would need to look into. It might be a very specific scan that is causing a problem, but they can likely help identify it and see if there is anything that needs to be done on our side to resolve it for good. I would recommend opening a support ticket with:
Simple curl request of that page
Response of the request
Logs from nsc.log when that request is made
That should get support the details they need to work with engineering.
Thanks Zak. The 500 is weird. My return using the reports API shows 4 pages (0,1.2,3)
When hitting with postman, pages 0, 3 work all the time. Pages 1 is always a 500 and Page 2 works rarely but 500 usually. I opened a case with support. They can’t offer support for scripting or programming. I get that, but postman with a static page, there i something. I don’t see anything obvious in nsc.log.