Asana API - get all tasks and completion status - asana

I am trying to use the Asana API to get all tasks within a project, as well as whether they have been completed. This seems to require the use of the opt_expand parameter, but I am having no luck with the following URL (and combinations of it): https://app.asana.com/api/1.0/projects/XXXX/tasks?limit=10&fields=completed&opt_expand=completed. Is this possible with the Asana API currently?

You need to use the opt_fields parameter in your GET request. Asana does not support generalized queries like completed=true. However, you can query for all tasks for a particular project and then filter the tasks by their completed_at value. The completed_at field will return a read-only time (e.g.'2012-02-22T02:06:58.147Z') of when the task was completed or null if the task is incomplete.
To return all tasks related to a project, including if they are complete, use this GET request: /projects/XXXX/tasks?opt_fields=name,completed_at.
For your reference, you can specify the options you want returned by using the parameters outlined in the Asana Input/Output Option docs. Also make sure to read the Asana Tasks docs to see which fields are available for the task resource.

Related

Get all planner tasks created by an user

I want to get all tasks my user created.
I tried to use https://graph.microsoft.com/v1.0/drive/root/createdByUser/planner/tasks endpoint in the Graph Explorer, but I got error 500 (internal server error).
The official documentation is here: https://learn.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http
Do you have any suggestion how I can get all the planner tasks I created?
Tasks created by a user is not a supported query. People can lose access to tasks that they have created (e.g. if they are removed from groups). The closest operation you can do is to loop over the plans in the groups you are a member of, read the plans in those tasks and see which ones were created by your user. The API linked in the question will return the tasks assigned to you.

Asana: Query for all tasks in a workspace

I am using Asana REST API for connecting Asana tasks with our app. I would need to query for a task from our app, but I don't know in which project to search for that task. Is there a way to query for all tasks in a specific workspace?
As I can see from the documentation it is only possible to search in a specific project:
https://asana.com/developers/api-reference/tasks#query
If you need users to search for a task by name in your app, you should use Asana's typeahead search API. It provides search for objects from a single workspace. This endpoint should be used to query for objects when creating an auto-completion search feature. This API is meant to provide results quickly and should not be relied upon for accurate or exhaustive search results.
There is no single query to return all tasks in a workspace. As workplaces have many thousands of tasks, this query would be too broad (and too expensive).

Getting task creator in Asana API

I'm building an Asana API wrapper in python and trying to add functionality to get the creator of a task. As per the suggestion in this question: How to expose asana task creator? I'm loading the stories and inferring it from there but I assumed there'd be a story with the text 'created' as shows up in the web interface but the earliest story I see is always 'added to' then either a tag or project and there is no system story with the text 'created'
Is this the intended behavior of the API?
It's actually not the API but the fact that there actually isn't an event for the task being created - we store the creator and the creation time on the task, so it's kind of redundant (and saves creating a new DB object for every task creation - at scale the little things can add up). In the UI, we show task creation information inline with the other stories, but for the API you should just get that info from the task data itself.

Tags created via Asana API not associated with tasks are not returned in tags API call

In my tests... the newly created tag is not in the get request for tags when it isn't associated with a task. Once associated with a task it seems to appear in the response. However, once removed from a task it disappears from response.
For all intents and purposes, a tag that's no longer associated with any tasks doesn't exist. You may still see autocomplete suggestions due to caching in the web client, but the API won't show them anymore.
The long-term goal is to have tags simply behave like text labels. A string would uniquely identify a tag, and we can stop messing around with IDs and pretending they're proper resources.

Asana API roadmap - getting completed tasks (including archived)

Do you plan to add possibility to retrieve (via API) all tasks from project including those which are archived?
(I work at Asana)
That would be a useful feature and we are already planning on adding it. However, I can't comment as to when it will be possible.
Until the API officially supports this, you can always query /tasks?completed_since=now to get only incomplete tasks, then query /tasks, and filter for tasks that only appear in the second list.
Archived tasks can be accessed by including the parameter ?include_archived=true in your request for querying tasks by project.
Task section in Asana documentation
I am trying to do this exact same thing as well. We are using a project to track line down events on our manufacturing floor. I found this post helpful and you can append “?include_archived=true” to your query but I found out that you can also do a reverse lookup on tasks by their tag. This will also show achieved tasks as well.

Resources