在AtTask API调用中,当我需要返回超过2000条记录时,如何使用分页?
例如,考虑到开发者网站 https://developers.attask.com/api-docs/#Basics 的以下内容我看到以下内容
Paginated Responses
To override the default number of results and set the response to provide 200 results you would include the following in your query:
GET /attask/api/project/search?$$LIMIT=200
To ensure reliability and performance for other tenants in the system, the maximum allowed limit per query is 2000 objects. Attempting to specify a larger limit will result in an error.
Therefore, it is recommended you consider using paginated responses for large datasets. To specify the first result that should be returned, the
$$FIRST
filter can be added. The following will return results 201-250 for a query.
GET /attask/api/project/search?$$FIRST=201&$$LIMIT=50
我不明白的是如何弄清楚我一开始有多少个。如果我想下载系统中的小时数,我如何知道我需要调用多少次(是否有 count(*)
)或类似的方法?我是否只是简单地获取前 2k,处理,尝试获取下一个 2k,如果不为空则处理?冲洗并重复?
最佳答案
由于初始搜索只会提取 2000 个结果,因此您必须迭代并提取下一个 2000 个结果,直到没有结果为止。
关于java - AtTask API 中超过 2000 条记录的分页示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27612316/