I am not sure about Asana Python SDK + code snippets, I am not that experienced in Python, I am just looking for ways to get extra data which does not come though PowerBI connector.
So I copied the following code:
import asana
from asana.rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: oauth2
configuration = asana.Configuration()
configuration.access_token = '<YOUR_PERSONAL_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)
# create an instance of the API class
api_instance = asana.TasksApi(api_client)
task_gid = '321654' # str | The task to operate on.
opt_fields = ["actual_time_minutes","approval_status","assignee","assignee.name","assignee_section","assignee_section.name","assignee_status","completed","completed_at","completed_by","completed_by.name","created_at","created_by","custom_fields","custom_fields.asana_created_field","custom_fields.created_by","custom_fields.created_by.name","custom_fields.currency_code","custom_fields.custom_label","custom_fields.custom_label_position","custom_fields.date_value","custom_fields.date_value.date","custom_fields.date_value.date_time","custom_fields.description","custom_fields.display_value","custom_fields.enabled","custom_fields.enum_options","custom_fields.enum_options.color","custom_fields.enum_options.enabled","custom_fields.enum_options.name","custom_fields.enum_value","custom_fields.enum_value.color","custom_fields.enum_value.enabled","custom_fields.enum_value.name","custom_fields.format","custom_fields.has_notifications_enabled","custom_fields.is_formula_field","custom_fields.is_global_to_workspace","custom_fields.is_value_read_only","custom_fields.multi_enum_values","custom_fields.multi_enum_values.color","custom_fields.multi_enum_values.enabled","custom_fields.multi_enum_values.name","custom_fields.name","custom_fields.number_value","custom_fields.people_value","custom_fields.people_value.name","custom_fields.precision","custom_fields.resource_subtype","custom_fields.text_value","custom_fields.type","dependencies","dependents","due_at","due_on","external","external.data","followers","followers.name","hearted","hearts","hearts.user","hearts.user.name","html_notes","is_rendered_as_separator","liked","likes","likes.user","likes.user.name","memberships","memberships.project","memberships.project.name","memberships.section","memberships.section.name","modified_at","name","notes","num_hearts","num_likes","num_subtasks","parent","parent.created_by","parent.name","parent.resource_subtype","permalink_url","projects","projects.name","resource_subtype","start_at","start_on","tags","tags.name","workspace","workspace.name"] # list[str] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. (optional)
try:
# Get a task
api_response = api_instance.get_task(task_gid, opt_fields=opt_fields)
pprint(api_response)
except ApiException as e:
print("Exception when calling TasksApi->get_task: %s\n" % e)
I pasted it into an empty Python project in PyCharm, and limited the fields to pull (obviously I had to install asana and pprint packages for first). So my code is exactly this:
import asana
from asana.rest import ApiException
from pprint import pprint
if __name__ == '__main__':
configuration = asana.Configuration()
configuration.access_token = 'my personal token here'
api_client = asana.ApiClient(configuration)
# create an instance of the API class
api_instance = asana.TasksApi(api_client)
task_gid = 'some specific task id here' # str | The task to operate on.
opt_fields = ["tags", "tags.name"]
try:
# Get a task
api_response = api_instance.get_task(task_gid, opt_fields=opt_fields)
pprint(api_response)
except ApiException as e:
print("Exception when calling TasksApi->get_task: %s\n" % e)
But this is what it returns:
{'data': {'actual_time_minutes': None,
'approval_status': None,
'assignee': None,
'assignee_section': None,
'assignee_status': None,
'completed': None,
'completed_at': None,
'completed_by': None,
'created_at': None,
'created_by': None,
'custom_fields': None,
'dependencies': None,
'dependents': None,
'due_at': None,
'due_on': None,
'external': None,
'followers': None,
'gid': '55555555......my actual task id here',
'hearted': None,
'hearts': None,
'html_notes': None,
'is_rendered_as_separator': None,
'liked': None,
'likes': None,
'memberships': None,
'modified_at': None,
'name': None,
'notes': None,
'num_hearts': None,
'num_likes': None,
'num_subtasks': None,
'parent': None,
'permalink_url': None,
'projects': None,
'resource_subtype': None,
'resource_type': None,
'start_at': None,
'start_on': None,
'tags': [],
'workspace': None}}