rest - API 请求协助
问题描述
我不熟悉调用第三方 REST API。
我有一个需要 ID (/sites/{id}/) 的 API。因为我不知道我头顶上的 ID 并且想查询多个 ID,所以无论如何要通配此 ID 以使其运行通过并检查实例 ID 的 1 到 10?或者这更像是一个 python 集成?
解决方案
如上所述,如果一个 API 恰好有一个参数“id”,那么是否可以扫描所有可用的 ID(或 1 到 10 之间的任何 ID)完全取决于 API。
在您的情况下,API(用于 help.rapid7.com)有据可查。它似乎有一个“列出站点”的端点,它应该给你你正在寻找的东西:
https://help.rapid7.com/insightvm/en-us/api/index.html#operation/getSites
Sites GET /api/3/sites Server URL https://help.rapid7.com/api/3/sites Retrieves a paged resource of accessible sites. PARAMETERS Query Parameters * page integer <int32> Default: 0 The index of the page (zero-based) to retrieve. * size integer <int32> Default: 10 The number of records per page to retrieve. * sort Multiple query params of string The criteria to sort the records by, in the format: property[,ASC|DESC]. The default sort order is ascending. Multiple sort criteria can be specified using multiple sort query parameters.
您可能想要执行以下操作:
- 调用
/api/3/sites
(带有过滤器)以获取您感兴趣的网站列表,然后 /sites/{id}/
为您想要详细信息的列表中的每个站点进行连续调用。
推荐阅读
- dart - OSx 上的 gRPC、ProtoCol BUffer 和 Flutter
- c# - Azure 存储过程不会将插入的 ID 返回给 ASP.NET 应用程序
- python - 在函数中返回后使列表为空
- javascript - Highcharts:仅渲染百分比条使用类型:'xrange'
- ios - 是否可以在使用 Fabric / Crashlytics 启动时查看先前崩溃的堆栈跟踪?
- visual-studio - Visual Studio 2017 - TFS 回滚
- java - 在java中加载的图像上绘制对象
- postgresql - 如何在 REASSIGN OWNED 等 SQL 语句中引用 PostgreSQL 过程的参数值?
- reflection - D有反射吗?
- android - 颤动 - 未检测到添加 AVM