我正在尝试从我的Asana列表中下拉自定义字段的值。我正在使用Official Python client library for the Asana API v1。
我的代码目前看起来像这样;
import asana
api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client = asana.Client.basic_auth(api_key)
me = client.users.me()
all_projects = next(workspace for workspace in me['workspaces'])
projects = client.projects.find_by_workspace(all_projects['id'])
for project in projects:
if 'Example Project' not in project['name']:
continue
tasks = client.tasks.find_by_project(project['id'], {"opt_fields":"this.name,this.custom_fields"}, iterator_type=None)
for task in tasks:
if "Example Task" in task['name']:
print "Matching task found."
print task['name'] + " - " + str(task['id'])
print task['custom_fields']
print
我得到了输出;
Matching task found.
Example Task - 228660596773016
[None, None]
Matching task found.
Example Task 2 - 228660596773021
[None, None]
“无”值的数量等于自定义字段的数量。如何获取密钥名称和值?我的最终目标是验证价值并更新为必需品。
答案 0 :(得分:0)
我已经尝试了一点,并设法重现你所拥有的问题。你能试试opt_fields":"this.name,custom_fields
吗?