Closed travelmail26 closed 4 years ago
Sorry that this is confusing! There's two endpoints that allow you to "search" for tasks.
completed_since
is a parameter for GET /tasks
(https://developers.asana.com/docs/get-multiple-tasks). The python method for this is client.tasks.get_tasks
.
The search endpoint is at GET /workspaces/{workspace_gid}/tasks/search
and has the python method client.tasks.search_in_workspace
(https://developers.asana.com/docs/search-tasks-in-a-workspace). The param you should use here is completed
.
The reason these endpoints both exist is because the /tasks
endpoint offers paging, has limited filters, and offers the most up to date data. The /search
endpoint offers a lot of filters, but has other tradeoffs (see https://developers.asana.com/docs/search-tasks-in-a-workspace).
Hope this helps! I'll close this issue, but let me know if you're not unblocked!
@rossgrambo This is so helpful! It mostly worked, but im still confused on how to get expanded filters or search criteria. I want to include other information, like notes, on each task i get. what is the proper syntax for that. The documentation on the asana website gives syntax for HTTP requests, but I’m having difficulty figuring out how to put that into the python syntax. Thanks so much for the help
This works for me:
tasks = client.tasks.get_tasks({"project": project, "completed_since": "now", "opt_fields": "notes"})
for item in tasks:
print(item)
If you want more than just notes
, make it a comma separated list like: notes,assignee,etc
@rossgrambo that seems to work too! thanks. someone on the asana forums suggest i use the search end-point but this looks just as fast. Just a recommendation for the documentation: it would be helpful to have an example or two in the readme files or in """
I'm having difficulty figuring out the syntax to search for completed items from the client.tasks.search_in_workspace. the documentation says that completed_since=now will return only completed answers, but when tried it, it didn't work. How exactly it is written? I tried something like
`client.tasks.search_in_workspace([workspace id], params={'text': {'job', 'completed_since=now'}})
What is the proper syntax for getting completed tasks? Thanks