How can I construct the URL for a task in My Tasks?

my-tasks
api

#1

I’m trying to build an integration that provides a link to a task a user has added in My Tasks. As discussed in Getting a user’s “My Tasks” Project ID, My Tasks is a built-in “project”, and the project ID My Tasks isn’t exposed by the API.

If you call /tasks with opt_fields=projects.id, you will see that tasks in My Tasks have no project. Example request:
GET https://app.asana.com/api/1.0/tasks?workspace=workspace-id&assignee=me&opt_fields=projects.id&limit=20

So, how can I construct (or request) the URL for a task in My Tasks? I tried seeing if there was an undocumented url field on tasks (i.e. /tasks?opt_fields=url) but there is not. I’m able to construct a URL for tasks in projects, but I’m not able to construct a URL for tasks that are only in My Tasks.


Getting a user's "My Tasks" Project ID
#2

If you construct a URL that looks like this:
https://app.asana.com/0/0/{taskID}
and that task exists only in My Tasks, then in my testing when that URL is executed, Asana replaces the second “0” with the Project ID of “My Tasks” and displays that task in the My Tasks view.


#4

Oh sweet, will give that a try. Thanks!

It’s probably better for your API than the <user-id+1> looping hack mentioned here: Programmatically attach user object in notes field I got the loop hack working but will replace the hack with this.


#5

This works, but there is one downside. My app stores various canonical URLs in a table, and the competing URL formats lead to 2 records when I really just want a single record:
https://app.asana.com/0/{projectId}/{taskId}
https://app.asana.com/0/0/{taskId}

It would still make the most sense to provide /tasks?opt_fields=url to get the URL for a task. Thanks for your help.