I'm building an app coded in Java/Android and using the Google Task API but I have hit a major problem.
I try to enter a Due or Completed date the Task API returns a 'Bad Request' error. I have however managed to post tasks successfully when I don't attempt to set a Due or Completed date.
I have spent hours researching this issue the closest I have found to a solution is the following thread:
I have attempted to set the task's status along with a date as mentioned in the thread but that doesn't seem to work for me.
I presuming I have formatted the DateTime wrong, although I'm just using a DateTime as specified in the Google docs (com.google.api.client.util.DateTime).
This is an example of a typical DateTime value that I'm attempting to use:
2011-10-03T22:28:626
I have tried the following code...
DateTime date = new DateTime(new Date());
Task task = new Task();
task.setTitle("Hello World");
task.setDue(date);
task.setStatus("needsAction");
and ...
DateTime date = new DateTime(new Date());
Task task = new Task();
task.setTitle("Hello World");
task.setCompleted(date);
task.setStatus("completed");
I would be very grateful if anyone can help me.
Thank you.
Thank you for everyone who viewed.
After a little more digging I found the answer so here it is...
The Google Task API currently only accepts a DATETIME.
I was providing a DateTime but the format was incorrect, I had to add a Time Zone Shift Integer. e.g. com.google.api.client.util.DateTime.DateTime(long value, Integer tzShift).
I simply did the below instead and it worked.
DateTime date = new DateTime(System.currentTimeMillis(), 0);
Task task = new Task();
task.setTitle("Hello World");
task.setDue(date);
task.setStatus("needsAction");