Dependencies are now available in the API

Today we launched another feature in our API: the ability to view and modify dependencies between tasks. Dependencies (and dependents) are available as a field on task objects and we have also added new endpoints to create and remove these relationships.

Have a look at the docs and let us know what you think!

7 Likes

I can’t wait for instagantt to implement this so we can see when project menager set dependencies we can see it in Asana and not just in instagantt app.

Hi Joe_Trollo, I’m trying to set dependencies to my tasks using python API (GitHub - Asana/python-asana: Official Python client library for the Asana API v1) but I’m not sure if Asana has any support for this. It’s not implemented any method for setting dependencies between tasks os subtasks.

Do you know any available python API continuously updated?

Thank you.

Hi @Breno_Carneiro_Pinhe,

Thanks for asking! We generate all of our client libraries from an upstream source, so supporting them all at the same time means we currently have a backlog on newer API features. In the meantime, you can use the workaround of using the post method on the client, i.e. instead of having something like

self.tasks.addDependency(taskId, params, **options)

you can use

self.client.post("/tasks/%s/addDependency" % (taskId), params, **options)

When our libraries are updated the underlying implementation will end up looking very similar to, say, self.tasks.addProject which you can use for a hint about what the API call directly on our client will look like. You can just do the equivalent 2 lines of code, and replace it with the clearer/nicer one on the next client library release.

Thanks, and we hope to catch up our client libraries to the new dependencies endpoints soon! In the medium term, we’re working to get to a state where our client libraries are easier to keep in sync with API endpoints, so thanks for your patience for now.

1 Like

Matt, thank you a lot for your reply. I’m not sure about the correct call for post method because of the field **option.

I’m trying something like: (I already have the ids of my task1 and task2)

import asana as asn

client = asn.Client.access_token(ASANA_ACCESS_TOKEN)

client.post(" https://app.asana.com/api/1.0/tasks/%s/addDependency" % (task[ā€˜id’]),{ā€˜dependencies’:[task_dependencie[ā€˜id’]]})

however I don’t know what to set in **option field. How is the correct way to call this method? Can you paste an example?

Thank you again.

Happy to help @Breno_Carneiro_Pinhe!

The options variable is an example of a keyword argument - it’s often seen in method calls as kwargs instead of options. It basically says ā€œSlurp up any additional arguments as key=value pairs into a Python dictionaryā€. We use it in cases like this (overriding the page size):

asn.client.tasks.create({projects=[12345]}, page_size=25)
                        ^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^
                        These are `params`  These are the **options

In this case, you don’t need it. If you had any additional arguments, like overriding the default pagination size of 50, you can pass them here, but it’s not required.

So I think the code that you wrote should work, assuming that task_dependencie is a JSON response of a task from a previous API call, with only one change: the client will automatically append the path on a built-in base URL. So try this:

client.post("/tasks/%s/addDependency" % (task[ā€˜id’]),{ā€˜dependencies’:[task_dependencie[ā€˜id’]]})

and let me know if you run into trouble!

Great!! Thanks a lot!

Regards,

Breno

@Joe_Trollo
Are dependency conflicts exposed in the API?

In the Gantt, conflicting dependencies are in red. (A task ends after the start of the blocked task). I want to be see in the API whether the dependency is conflicted (red) or not.

If not, which I don’t believe it is, how hard would it be to get this added?

Hi @Getz_Pro,

A couple of notes…

You are correct, the API does not include any information on conflicting dependencies.

Also, Joe Trollo is no longer with Asana. So I’m cc’ing a few current people: @Andrew-asana @Kem_Ozbek

1 Like

Thank you @Phil_Seeman

@Andrew-asana @Kem_Ozbek
any thoughts as to when this might make it into the API?

@Getz_Pro,

Obviously I’m not the Asana guys so they may weigh in, but I would say don’t expect it in the API as the API is a reflection of and just exposes functionality in the underlying web product, and there’s no functionality in the web product to report conflicting dependencies, so…