phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

Create Event With specific start and end times

Open zach7 opened this issue 6 years ago • 2 comments

I am able to create calendar events without specifying a start or end time, however I am having difficulty setting these times manually.

When attempting to create an event with a start/end structure similar to the examples here: https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations#CreateEvents

I receive one of the following two errors:

  • An unexpected 'StartArray' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected.
  • An unexpected 'StartObject' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected.

Inferring from this, I attempted to create an event with a simple string, like '2017-07-18T22:00:00Z' but receive this error message:

  • At least one property failed validation.

Is the DateTimeTimeZone class implemented for use, or is there another way that I should be structuring these start/end dates for event creation?

zach7 avatar Jul 17 '17 19:07 zach7

Got this working by making the following modification:

In src/OutlookServices/Event.php: - Add attribute $End to Event Class: public $End;

An event can then be created by setting the Start and End attributes with the following date/time syntax: - new_event->Start = "2017-07-19T15:31:00Z"; - new_event->End = "2017-07-19T16:31:00Z";

zach7 avatar Jul 18 '17 20:07 zach7

Could you possibly share any of the code you're using to create events? I'm trying to test this functionality, but haven't gotten it working.

F4T4LERROR avatar Nov 24 '21 15:11 F4T4LERROR