I am trying to get events of a group calendar within a specific range. Already found this post:
Microsoft Graph SDK .NET get events in range
Then tried to adopt the code provided in the above post to fit my needs:
DateTime dateStart = DateTime.Parse("2019-13-06T00:00:00"), dateEnd = dateStart.AddDays(30);
List<QueryOption> options = new List<QueryOption>()
{
new QueryOption("startDateTime", dateStart.ToUniversalTime().ToString()),
new QueryOption("endDateTime", dateEnd.ToUniversalTime().ToString())
};
var eventsInRange = await graphClient.Groups[groupId]
.Calendar
.CalendarView
.Request(options)
.GetAsync();
The result was, that eventsInRange
was not null but the resultset of events did not contain any element.
There are events in the specific calendar and I get them when using this code:
events = await graphClient.Groups[groupId]
.Calendar
.Events
.Request()
.GetAsync();
Did not find a lot of information about that in the official microsoft documentation. So it's hard to guess what I did wrong.
Would be great if anyone has some helpful idea.
Thanks in advance!
I found a solution myself and this is what I found out. Maybe it will be helpful for someone else too:
This code was inside of a try-catch-block and therefore I got no exception during debugging as long as I put a breakpoint into the catch block. That showed me an error pointing to a missformatted datetime string.
What solved the problem was an additional formatstring for the ToString() method:
new QueryOption("startDateTime", dateStart.ToUniversalTime().ToString("o"))
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.