1

I am trying to update a subtask. More specifically just the due date. I have tried several things and have failed. This is what I have tried so far:

Attempt 1: URL: https://app.asana.com/api/1.0/tasks/ JSON: {"data":{"due_on":"6/18/2017 12:00:00 AM"}} Error: The remote server returned an error: (400) Bad Request.

Attempt 2: Added a parent id to JSON request URL: /tasks/ JSON: ParentID is masked for security reasons {"data":{"due_on":"6/18/2017 12:00:00 AM","parent":{"id":################,"name":null}}} Error: The remote server returned an error: (400) Bad Request.

attempt 3: using /subtask in URL URL: /tasks//subtasks/ JSON: {"data":{"due_on":"6/18/2017 12:00:00 AM"}} ERROR: The remote server returned an error: (404) Not Found

What should be the correct URL to send the JSON request and what should be in the request to modify the subtask due date ?

Any help is greatly appreciated. Thanks Viv

1 Answers1

2

Vivek,

The first thing I noticed is that the URL doesn't contain the ID of the task you're trying to update - I'm not sure if this is a copy-paste omission in the question, but if not and the URL you're using doesn't have the ID of the task, we won't know which task you're trying to set the due date for - so that might be one thing you're seeing :)

Additionally, I'd like to verify that you're using the HTTP verb PUT for these requests; you can POST new tasks in Asana, but to change fields on an existing task, we expect a PUT. Since subtasks count as tasks in Asana, this can be done just against https://app.asana.com/api/1.0/tasks/:task_id route

One more thing: setting the due date or due time in Asana are actually 2 separate things - most tasks have their due date set, but in our web app you can choose to add the time when setting the due date. This is represented in our API by the fields due_on for dates and due_at for times. If you just want the due date (inferred by the fact that the time is 12:00 AM) you'll probably want due_on and a string whose format is YYYY-MM-DD (in this case, 2017/06/18). If you want to set the actual time, you can use due_at with an ISO8601 timestamp, such as 2017-06-18T08:00:00Z

Putting it all together, here's a curl request I tested here with "due_at" to keep the time aspect in:

curl --request PUT \
--header "Authorization: Bearer $ASANA_PERSONAL_ACCESS_TOKEN" \
"https://app.asana.com/api/1.0/tasks/$TASK_ID" -d '{
  "data": {
    "due_at": "2017-06-08T12:00:00Z"
  }
}'

Finally, and completely unrelated: do you happen to be the Vivek Patel currently working for Yelp? If so, I used to work with you at Sharpcast - small world! If not, no worries, feel free to ignore!

Matt
  • 10,434
  • 1
  • 36
  • 45
  • My date format was wrong. Once corrected, Subtasks are updating the dates. Thanks for pointing me in the right direction. It seems that when an API is used to create a subtask, they show up on the calendar, but when the subtask are created using the ASANA website, the sub tasks are not on the calendar but are within the task. Is there something I need to correct so the subtask do not show up on the calendar ? – Vivek Patel Feb 06 '17 at 20:39
  • Hmm, interesting. Sounds like that may actually be a bug - I'll file it to bring it to the team's attention. Thanks! – Matt Feb 10 '17 at 21:41