Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,796 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Please take a look at below event body, I have added room resource as a location and also added it as attendee. After booking event - I am expecting that same event will appear in all attendee calendar but room calendar is not having the event created.
DateTime dateTime = DateTime.Today;
string subject = "TestCSharpCalendar-FromCode";
string startTime = startTimeValue; //"20";
string endTime = endTimeValue; // "21";
DateTimeTimeZone start = new DateTimeTimeZone
{
TimeZone = "India Standard Time",
DateTime = $"{dateTime.Year}-{dateTime.Month}-{dateTime.Day + 1 }T{startTime}:00:00"
};
DateTimeTimeZone end = new DateTimeTimeZone
{
TimeZone = "India Standard Time",
DateTime = $"{dateTime.Year}-{dateTime.Month}-{dateTime.Day + 1}T{endTime}:00:00"
};
Location location = new Location
{
DisplayName = placedetails.DisplayName,
LocationEmailAddress = roomEmail,
UniqueId = roomEmail,
LocationType = LocationType.ConferenceRoom,
//ODataType = "microsoft.graph.room",
//Address = placedetails.Address,
//AdditionalData = placedetails.AdditionalData,
//Coordinates = placedetails.GeoCoordinates,
};
List<Location> locationList = new List<Location>();
locationList.Add(location);
Attendee attendee = new Attendee
{
EmailAddress = new EmailAddress { Address = "varXXX@xnuvXXX.onmicrosoft.com" },
Type = AttendeeType.Required,
};
Attendee attendeeRoom = new Attendee
{
EmailAddress = new EmailAddress { Address = roomEmail },
Type = AttendeeType.Resource,
Status = new ResponseStatus { Response = ResponseType.Accepted}
};
List<Attendee> attendees = new List<Attendee>();
attendees.Add(attendee);
attendees.Add(attendeeRoom);
Recipient org = new Recipient
{
EmailAddress = new EmailAddress { Address = "ankush.j@xnuvXXX.onmicrosoft.com" }
};
Event newEvent = new Event
{
Subject = subject,
Attendees = attendees,
Start = start,
End = end,
Location = location,
Locations = locationList,
Organizer = org
};
var organizerEmail = newEvent.Organizer.EmailAddress.Address;
Event calendarEvent = await graphClient.Users[organizerEmail]
.Calendars["AAMkAD..."]
.Events
.Request().AddAsync(newEvent);