如何使用 Trello 的 Rest API 获取板的所有操作? [英] How can I get all Actions for a Board using Trello's Rest API?

查看:16
本文介绍了如何使用 Trello 的 Rest API 获取板的所有操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取一个板的所有操作,但 Trello 将结果限制为 1000.我理解处理这个问题的正确方法是分页.我试过 beforepage 作为关键字:

I want to get all the actions for a board, but Trello limits the results to 1000. I understand the correct way to deal with this is to paginate. I've tried both before and page as keywords:

基本调用:

https://api.trello.com/1/board/[boardID]/
         ?key=[key]&token=[token]
         &actions=commentCard&actions_limit=1000

替代方案:

之前:

https://api.trello.com/1/board/[boardID]/
         ?key=[key]&token=[token]
         &actions=commentCard&actions_limit=1000&
         before=[oldest_returned_action's_date]

页面:

https://api.trello.com/1/board/[boardID]/
         ?key=[key]&token=[token]
         &actions=commentCard&actions_limit=1000&
         page=[page_number]

结果永远不会改变 --- 我总是得到 [limit] 次操作,无论调用多少,它们总是相同的.我检查了返回内容中的日期,他们当然不尊重 before 参数.我什至尝试降低限制以确保我不会试图返回超过我拥有的东西.问题依旧.

The result never varies --- I always get back [limit] number of actions, and they're always the same no matter the call. I checked the dates in what was returned and they certainly don't respect the before parameter. I even tried lowering the limit to make sure I wasn't trying to return more than I possessed. The problem persists.

如何正确获取 Trello 看板的所有操作?

How can I correctly get all actions for a Trello board?

推荐答案

动作是按时间倒序排列的(从最新到最旧),所以要翻阅看板上的动作,你可以使用类似的东西:

Actions are in reverse chronological order (newest-to-oldest), so to page through the actions on a board, you would use something like:

curl "https://api.trello.com/1/boards/${BOARD_ID}/actions/?key=${TRELLO_API_KEY}&token=${TRELLO_TOKEN}&limit=1000"

然后,从上面返回的数组的最后一个元素中,选择 dateid 并将其作为 before 传递下一次调用中的参数,例如:

then, from the last element of the array returned by the the above, select the date or id and pass that as the before parameter in the next call, e.g.:

curl "https://api.trello.com/1/boards/${BOARD_ID}/actions/?key=${TRELLO_API_KEY}&token=${TRELLO_TOKEN}&limit=1000&before=${DATE_OR_ID_OF_LAST_ACTION}"

并重复,将最后一个操作的 iddate 作为后续 before 参数传入.

and repeat, passing in either the id or date of the last action as the subsequent before parameter.

这篇关于如何使用 Trello 的 Rest API 获取板的所有操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆