问题
I'm trying to pull down the values of custom fields from my Asana list. I'm using the Official Python client library for the Asana API v1.
My code currently looks like this;
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
I get the output;
Matching task found.
Example Task - 228660596773016
[None, None]
Matching task found.
Example Task 2 - 228660596773021
[None, None]
The number of "None" values is equal to the number of custom fields. How can I get the key name and the value? My ultimate goal is to verify the value and update as nessesary.
回答1:
I've experimented a little and managed to reproduce the issue you're having. Can you try opt_fields":"this.name,custom_fields
?
来源:https://stackoverflow.com/questions/41093759/how-can-i-access-custom-fields-from-asana-api-using-python