I am new to the API, and trying to set up a webhook in a different application (Ziflow) that will update a multi-select field in Asana without replacing the options that are currently selected.
I am able to get the following JSON to work with PUT https://app.asana.com/api/1.0/tasks/{task_gid}, but it is rewriting any currently selected options to only include the update. Am I missing something that would allow it to add instead of replace?
No, afraid there is no facility within the API to add a value to an existing multi-select custom field; you have to supply all of the values for that field that you want on that task. This means you’ll need to read the task, get the existing values, then build your array to include all of the existing ones plus the new one.
I’ve not used Ziflow before but hopefully it will provide you with the ability to do that. If not, there are other ways to accomplish it but that might or might not be of interest to you depending on whether you’re locked into just using Ziflow.
Thank you for the insight, Phil! I will see if I can get something like that to work within Ziflow. We are locked into Ziflow being the starting point where this information is coming from, but depending on cost, we are able to use other tools, so if you have other suggestions, I would love to hear them!
The payload you’re sending effectively says “set this custom field to this value,” not “add this value to the existing set.” For multi-select custom fields, updates are replace-all.
The correct flow is:
GET the task to read the current selections
Merge the new option GID into that list
PUT the full array of option GIDs back to the task
If Ziflow can fetch the task first, it should be possible to implement the read-merge-write pattern there.