我无法理解Chargebee(https://apidocs.chargebee.com/docs/api)的分页,我需要创建一个请求,在其中可以向请求添加下一个偏移量以获取更多数据(默认情况下没有其他限制)是10)。但是我不明白如何使用给定的next_offset像附件图像那样形成http请求。
答案 0 :(得分:0)
我成功提交了相同的请求,并在最后加上了偏移。这是一个示例:
First Request
curl -s https://xxyyzz.chargebee.com/api/v2/events -G -K /home/xxyyzz/.cb_curl_key.cfg --data-urlencode limit=2 --data-urlencode occurred_at[between]="[1554076800,1554077099]"
JSON results:
{
"list": [
{"event": {
"id": "ev_xxyyzz1",
"occurred_at": 1554077022,
...
"next_offset": "[\"1556428868000\",\"364450353\"]"
}
The tool I used to display the json is trying to be helpful with the backslashes.
The real next_offset value is
["1556428868000","364450353"]
Second Request
Identical to the first with
offset="["1554077017000","345017569"]"
tacked on to the end:
curl -s https://xxyyzz.chargebee.com/api/v2/events -G -K /home/xxyyzz/.cb_curl_key.cfg --data-urlencode limit=2 --data-urlencode --data-urlencode occurred_at[between]="[1554076800,1554077099]" offset="["1554077017000","345017569"]"
JSON results:
{
"list": [
{"event": {
"id": "ev_xxyyzz3",
"occurred_at": 1556429028,
}
继续重复该过程,直到“ next_offset”键没有出现在JSON结果中为止。