简体   繁体   中英

Create all-day event in Google Calendar via API

I am trying to create an event in a Google Calendar via the API. The event should be all day , from '2016-03-04' to '2016-03-05'.

Here is the hash that I am sending in the POST body:

{
  "summary"     => "MyEvent", 
  "description" => "Just a Test", 
  "start"       => { "date" => "2016-03-04" }, 
  "end"         => { "date" => "2016-03-05" }, 
  "attendees"   => []
}

The response is a 400 error, stating Missing end time. as the error.

In the docs it says:

end.date    date    The date, in the format "yyyy-mm-dd", if this is an all-day event.

What am I missing here? How can I create events without explicit times?

Found the reason. I was actually not posting the event at all , the whole request body was a true (due to a stupid programming mistake).

The error the Google API sends back is quite misleading, since I did not even send a valid JSON hash.

When I actually do send the hash from my question, everything works fine and an end time is not needed .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM