0

I use google tasks api, Patch ().

This request not work:

{
  "status": "needsAction", 
} 

But this request is ok:

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

I use .NET and if I do so

var task = new Google.Apis.Tasks.v1.Data.Task () 
{
    Status = "needsAction", 
    Completed = null 
};

then, he just ignores "Completed" and I get an error.

The same problem: https://www.lima-city.de/thread/google-api-tasks

4 Answers4

0

Have you tried DateTime.MinValue instead of null ? Since it should be a DateTime type, and that is a struct which cannot be assigned a null. So Usually you should not assign it unlesss you need it or assign it with DateTime.MinValue or DateTime.MaxValue...

Also when you encounter an error, you should really pay attention to the information it provides. This is often the easiest way to solve the problem, by actually understanding what the errormessage tells you.

In your case however i guess you couldnt even compile since the null assignment to a datetime is illegal.

CSharpie
  • 9,195
  • 4
  • 44
  • 71
  • I tried to use the MinValue and MaxValue. It does not work. Completed is of type ?DateTime. It compiles. But Google returns an error "Invalid Value". Still there is a string field "CompletedRaw" (RFC 3339 timestamp). I tried to use CompletedRaw = "null" or String.Empty. But it generates an error "Invalid format" – Иван Субботин Sep 11 '14 at 05:10
0

I did some testing using the API Explorer at https://developers.google.com/google-apps/tasks/v1/reference/tasks/update#try-it and I found that the server needs the 'id' field as well as the 'status' field.

It does not need the 'completed' field, as the 'completed' field is automatically deleted on the server when the 'status' is set to "needsAction".

So, all you need is the original ID of the task.

e.g. (in the API Explorer for my sample task) { "status": "needsAction", "id": "MTQwMDY3NzIwMTg5MTk4MzczOTA6MDoxNjQzNjkwMDc5" }

I hope this helps,

Julie

https://groups.google.com/forum/embed/?place=forum%2Fgoogle-tasks-api&showsearch=true#!topic/google-tasks-api/Hj84P2guTyE

0

If the underlying call uses patch semantics, you must set completed to nil in the same operation when changing from status=completed to status=needsAction. This is by design.

Steven Spungin
  • 27,002
  • 5
  • 88
  • 78
0

With Using

Google.Apis.Tasks.v1

You have to define; Status = needsAction, Completed = null and also CompletedRaw = null.

c#

.Status = "needsAction";
.CompletedRaw = null;
.Completed = null;

VB.NET

.Status = "needsAction"
.CompletedRaw = Nothing
.Completed = Nothing
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135