+ Add Question

Sync API question about due_date


Hi, I'm testing out the new sync api and still having trouble. Specifically what is the format for passing due_dates when passing items for item_add and item_update? I try to leave them out and the server nulls out the due_dates for my task. I try to pass the date as a string but the server gives me an error, I tried passing the date in JS notation new Date(...) and still the server errors. The only thing that works is passing null as the due_date. How should I be formatting the due_date in order to get it to stick?

All responses

Amir Salihefendic  staff in training
Replied on Feb 06, 2012 - 08:32 UTC

Hi Andrew

You should only set date_string - - such as "today at 12pm" or "12 feb 2012" and Todoist will automatically parse and set the due_date attribute.

Best regards,

Andrew Hewitt  premium
Replied on Feb 06, 2012 - 08:53 UTC

Thanks for getting back to me. Perhaps I'm doing something wrong but I've tried it without due_date before and it didn't work. I also try it with due_date as null. Just now I did a few tests, even tried formatting the date_string differently but still the server does not save my date. Here's the JSON of one of the tasks sent, I've taken out actual ids:

api_token=...&items=[{"args":{"item_order":105,"priority":1,"project_id":10...,"id":"13...","indent":2,"content":"Testing date_string","date_string":"6 Feb 2012","due_date":null},"type":"item_update","timestamp":"1328539585.15"}]

Like I said I tried it also without passing the due_date at all in there and it doesn't stick. Help?

Andrew Hewitt  premium
Replied on Feb 29, 2012 - 02:58 UTC

This is listed as being answered but I'm still having the problem. Nothing I try works, please help. Can you test on your end and see if what I'm saying isn't in fact happening. My app is almost done but I won't be able to submit it until the sync is worked out.

Andrew Hewitt  premium
Replied on Feb 29, 2012 - 08:29 UTC

Ok, investigating further by looking at the calls being made by todoist.com itself to the server I was able to see that the due_date was indeed being passed but it was being passed in a specific date format. Formatting my dates in that way finally brought me some success. I'm now able to sync myself. Thanks for your help Amir (and David) and sorry for the bother.

For anyone else running into this, be sure to format your due_dates as "yyyy-M-d'T'HH:mm" for the server to accept them.