Richard Schneider
Richard Schneider

Reputation: 21

Adding new event to office365 calendar

I'd like to add new events to custom calendar (named "Calendar XY") using Office 365 API. I don't know why, but all events are always added into default calendar (named "Calendar").

_client.Me.Calendars[myCalendar.Id].Events.AddEventAsync(newEvent);

When inspecting using Fiddler I've noticited, that even when @odata.context was correct (with Id of "Calendar XY"), @odata.editLink still pointed to default calendar ID.

Here it is complete context, but I don't see there anything interesting:

        const string ExchangeResourceId = "https://outlook.office365.com";
        const string ExchangeServiceRoot = "https://outlook.office365.com/ews/odata";

        var _authenticator = new Authenticator();
        var authInfo = await _authenticator.AuthenticateAsync(ExchangeResourceId);
        var _client = new ExchangeClient(new Uri(ExchangeServiceRoot), authInfo.GetAccessToken);

        var myCalendar = await (
            from calendar in _client.Me.Calendars
            where calendar.Name == "Calendar XY"
            select calendar
            )
            .ExecuteSingleAsync();

        var newEvent = new Event
        {
            Start = dayData.DateTimeFrom,
            End = dayData.DateTimeTo,
            Location = new Location { DisplayName = dayData.Location },
            Subject = dayData.Subject,

            Importance = Importance.Low,
            ResponseRequested = false,
            ShowAs = FreeBusyStatus.Free,
        };

        await _client.Me.Calendars[myCalendar.Id].Events.AddEventAsync(newEvent);

Upvotes: 2

Views: 997

Answers (1)

user3724350
user3724350

Reputation: 11

First off, thank you for using the new Office 365 APIs! After digging into this, it appears as if this is a bug that is at the service layer. I opened up a tracking issue. We will need to dig into this and do some code changes on our side. We will be addressing this issue, however I don’t have an ETA as to when it will be fixed in the service. Thanks for the feedback!

David Los Senior Program Manager - Exchange

Upvotes: 1

Related Questions