CHJani / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Unable to perform Patch for "needsAction" using Java library #339

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.5.0-beta)?
google-api-java-1.5.1-beta
google-api-services-tasks-v1-1.2.5-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Android 2.3

Describe the problem.
Unable to change completed task to incomplete by using java client.

com.google.api.services.tasks.Tasks tasksService = ...; 
Task task = new Task(); 
 task.setId("someTaskID"); 
 task.setStatus("needsAction"); 
 task.setCompleted(null); 
 Patch patch = tasksService.tasks.patch("someTaskListID", task.getId(), task); 

The require field won't be generated. 
{ 
 "id": "xxx" 
 "status": "needsAction", 
 "completed": null                   <======. MISSING
}

{ 
 "id": "xxx" 
 "status": "needsAction", 
 "completed": null 
} 

How would you expect it to be fixed?

Original issue reported on code.google.com by cweny...@gmail.com on 3 Nov 2011 at 2:25

GoogleCodeExporter commented 9 years ago
Please try this:

task.setCompleted(Data.NULL_DATE_TIME);

That should result in a JSON null.

Original comment by yan...@google.com on 11 Nov 2011 at 10:09

GoogleCodeExporter commented 9 years ago
See:

http://javadoc.google-http-java-client.googlecode.com/hg/1.6.0-beta/com/google/a
pi/client/util/Data.html#NULL_DATE_TIME

Original comment by yan...@google.com on 11 Nov 2011 at 10:10

GoogleCodeExporter commented 9 years ago
I had the same problem and this fixed it.
Thanks for you answer, really made things much easier.

Original comment by gabriel....@gmail.com on 11 Nov 2011 at 10:19