Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy do I keep getting 'Bad Request' when I try to post a task in Java using the Google Task API?
    primarykey
    data
    text
    <p>I'm building an app coded in Java/Android and using the Google Task API but I have hit a major problem.</p> <p>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.</p> <p>I have spent hours researching this issue the closest I have found to a solution is the following thread:</p> <p><a href="http://groups.google.com/group/google-tasks-api/browse_thread/thread/1753df5bbc8e3cb8/ab66b5e675f06e6a?lnk=gst&amp;q=problem+changing#ab66b5e675f06e6a" rel="nofollow">http://groups.google.com/group/google-tasks-api/browse_thread/thread/1753df5bbc8e3cb8/ab66b5e675f06e6a?lnk=gst&amp;q=problem+changing#ab66b5e675f06e6a</a></p> <p>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.</p> <p>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).</p> <p>This is an example of a typical DateTime value that I'm attempting to use:</p> <blockquote> <p>2011-10-03T22:28:626</p> </blockquote> <p>I have tried the following code...</p> <pre><code>DateTime date = new DateTime(new Date()); Task task = new Task(); task.setTitle("Hello World"); task.setDue(date); task.setStatus("needsAction"); </code></pre> <p>and ...</p> <pre><code>DateTime date = new DateTime(new Date()); Task task = new Task(); task.setTitle("Hello World"); task.setCompleted(date); task.setStatus("completed"); </code></pre> <p>I would be very grateful if anyone can help me.</p> <p>Thank you.</p> <hr> <p>Thank you for everyone who viewed.</p> <p>After a little more digging I found the answer so here it is...</p> <p>The Google Task API currently only accepts a DATETIME.</p> <p>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).</p> <p>I simply did the below instead and it worked.</p> <pre><code>DateTime date = new DateTime(System.currentTimeMillis(), 0); Task task = new Task(); task.setTitle("Hello World"); task.setDue(date); task.setStatus("needsAction"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload