使用 Asana Python API 访问可选字段
Accessing optional fields using Asana Python API
我试图在通过 Asana 的 Python API Tasks.find_by_project()
进行调用时获取其他字段。我的通话代码是:
project_tasks = Tasks(self.client).find_by_project(project_gid, opt_fields= ["name", "memberships", "gid"])
我得到:
{'id': 408541814417314, 'gid': '408541814417314', 'memberships': [{}], 'name': 'Reports - Develop quality control report to run for MES'}
似乎我只能访问由紧凑任务记录填充的字段,但我需要额外的字段并且希望在不重新循环所有任务并获取完整任务的情况下获取它们。奇怪的是,它 returns 是一个空列表,但是当我查看完整的任务记录时,该任务有成员资格。
我看到了这个问题,它看起来很相似,但给定的(尝试过的)解决方案对我不起作用(我没有其他字段):
以防其他人遇到这个问题,我让你和 Asana 一起解决这个问题。 memberships
不可调用,您必须调用 Tasks(self.client).find_by_project(project_gid, opt_fields= ["name", "memberships.section", "gid"])
或 Tasks(self.client).find_by_project(project_gid, opt_fields= ["name", "memberships.project", "gid"])
您显然也可以调用 opt_expand=['memberships']
来获取所有数据。
来自体式:
Thanks for your patience!
We heard back from our Platform Team regarding the issue. What you are
experiencing is currently expected behavior, but it is not intuitive,
because the membership object doesn't have any data of its own.
If you wanted to get the nested data, you can specify which data you
want opt_fields=['memberships.project', 'memberships.section'] in
their opt_fields request. Another option is to use
opt_expand=['memberships'] to get all of the data.
Hope this helps! Let me know if there's anything else I can assist you
with.
我试图在通过 Asana 的 Python API Tasks.find_by_project()
进行调用时获取其他字段。我的通话代码是:
project_tasks = Tasks(self.client).find_by_project(project_gid, opt_fields= ["name", "memberships", "gid"])
我得到:
{'id': 408541814417314, 'gid': '408541814417314', 'memberships': [{}], 'name': 'Reports - Develop quality control report to run for MES'}
似乎我只能访问由紧凑任务记录填充的字段,但我需要额外的字段并且希望在不重新循环所有任务并获取完整任务的情况下获取它们。奇怪的是,它 returns 是一个空列表,但是当我查看完整的任务记录时,该任务有成员资格。
我看到了这个问题,它看起来很相似,但给定的(尝试过的)解决方案对我不起作用(我没有其他字段):
以防其他人遇到这个问题,我让你和 Asana 一起解决这个问题。 memberships
不可调用,您必须调用 Tasks(self.client).find_by_project(project_gid, opt_fields= ["name", "memberships.section", "gid"])
或 Tasks(self.client).find_by_project(project_gid, opt_fields= ["name", "memberships.project", "gid"])
您显然也可以调用 opt_expand=['memberships']
来获取所有数据。
来自体式:
Thanks for your patience!
We heard back from our Platform Team regarding the issue. What you are experiencing is currently expected behavior, but it is not intuitive, because the membership object doesn't have any data of its own.
If you wanted to get the nested data, you can specify which data you want opt_fields=['memberships.project', 'memberships.section'] in their opt_fields request. Another option is to use opt_expand=['memberships'] to get all of the data.
Hope this helps! Let me know if there's anything else I can assist you with.