OfficeDev / Office-365-SDK-for-Java

Office 365 client for Java
Other
48 stars 39 forks source link

Unable to create a single day all day event #5

Open garybentley opened 9 years ago

garybentley commented 9 years ago

It seems impossible to create a single day (24 hour) all day event.

If I try and set the start/end dates to be the same then I get error:

"The duration of an event marked as All day must be at least 24 hours."

If I set the end date to be start date + 1 day then the date spans 2 days in the Office 365 calendar.

If I try and set the end date to be start date - 1 second then I get an error saying that all day events must have their times set to midnight.

I've set the timezone to "Greenwich Standard Time" for the start and end time zone.

Is there something I'm missing or is it just not possible?

marcote commented 9 years ago

Hi @garybentley

You should try to create a payload like the following:

{
   "Attendees":[
      {
         "EmailAddress":{
            "Address":"foo@bar.com",
            "@odata.type":"#Microsoft.OutlookServices.EmailAddress"
         },
         "@odata.type":"#Microsoft.OutlookServices.Attendee"
      }
   ],
   "Body":{
      "Content":"This is the appointment info",
      "ContentType":"Text",
      "@odata.type":"#Microsoft.OutlookServices.ItemBody"
   },
   "End":"2015-09-09T00:00:00.000Z",
   "Importance":"High",
   "IsAllDay":true,
   "Start":"2015-09-08T00:00:00.000Z",
   "Subject":"Today's appointment",
   "@odata.type":"#Microsoft.OutlookServices.Event"
}

Please check the Start and End properties. Both must be set with at midnight but at different dates ( + 1) Sadly the date handling in Java is less than ideal, but this creates a successful POST request.

Thanks

marcote commented 9 years ago

I added a sample written in Android, but applies to this case:

https://github.com/OfficeDev/Office-365-SDK-for-Android/commit/ad2b9bf229ea0303f992c173274323bdf98e54a0#diff-6c22519e82f0e605df2f8275b6b3ded2R2211

garybentley commented 9 years ago

Sorry but this doesn't address the issue, using your exact code from the Android example I get the same result. In the Office 365 calendar the event shows up as spanning 2 days, in the events list for the day it says that it's duration is "1 day" but it will show that for both days, say if I click on the 8th then the 9th Sept.

Is this an issue with the Office 365 calendar interface instead?

marcote commented 9 years ago

@garybentley yes. Now I understand. Sadly I'm facing the same issue. I found this : http://stackoverflow.com/questions/28982218/all-day-events-is-not-created-correctly-in-office-365 . Please try it. Anyway I'm contacting the API owner for further information.

hotcakedev628 commented 3 years ago

If an event is allday for a day, then it will be the same date and time, right? Then should I add a day manually to the end date? And after creating an event like that, then should I subtract a day to get the event? What is the correct all day event?