Dependencies are now available in the API

dependencies
api

#1

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!


#2

#3

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.


#4

Hi Joe_Trollo, I’m trying to set dependencies to my tasks using python API (https://github.com/Asana/python-asana) 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.


#5

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.


#7

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.


#8

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!


#9

Great!! Thanks a lot!

Regards,

Breno