【问题标题】:Get a list of all tasks and subtasks from Asana REST API从 Asana REST API 获取所有任务和子任务的列表
【发布时间】:2020-01-21 03:59:43
【问题描述】:

我正在尝试通过点击 REST 端点https://app.asana.com/api/1.0/tasks?project=1234&opt_fields=... 来获取 Asana 项目的所有任务和子任务,但这只会给出任务,而不是所有子任务或子子任务等。我没有看到任何其他端点对于访问所有子任务,看起来我只能通过将subtasks.name 等作为 opt_fields 的一部分或通过/tasks/987/subtasks 端点访问子任务来获取此信息。但是,这具有使用速率受限的后端发出许多远程请求的所有缺点。

【问题讨论】:

    标签: ruby asana asana-api


    【解决方案1】:

    目前没有获取所有任务、子任务和子子任务的方法。最接近的方法是添加subtasks.namesubtasks.id 等。在这种情况下,我可以点击端点https://app.asana.com/api/1.0/tasks?project=1234&opt_fields=id,name,subtasks.name,subtasks.id,etc,我只需要访问子任务中的一些字段。从端点获得结果后,我可以像这样提取子任务(在 ruby​​ 中):

    tasks = get_tasks_from_api()
    subtasks = tasks.map { |t| t.subtasks } # this is an array of arrays [[x,y],[z]] etc
    subtasks = subtasks.flatten # make into just an array [x,y,z]
    subtasks = subtasks.compact # make sure there are no nils
    
    tasks = tasks + subtasks # this will be all tasks followed by all subtasks
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-04
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多