英文:
How to determine which calendar an event is on?
问题
有没有一种简单的方法可以确定事件所属的日历?
例如,如果我有一个事件的ID,我可以这样做:
Event event = graphClient
.me()
.events()
.byId(eventId)
.buildRequest(options)
.get();
现在我有了这个事件,如何确定它属于哪个日历?事件中似乎有一个日历属性,所以我可以尝试做类似这样的事情:
String calendarName = event.calendar.name;
但由于某种原因,日历属性总是为空,所以这行代码行不通。
英文:
Is there an easy way to determine which calendar an event is on?
For example, if I have an the ID of an event I can do the following:
Event event = graphClient
.me()
.events()
.byId(eventId)
.buildRequest(options)
.get();
Now that I have that event, how do I determine which calendar it is from? There appears to be a calendar property in the event, so I could try to do something like
String calendarName = event.calendar.name;
For some reason though, the calendar property is always null so that won't work.
答案1
得分: 3
你可以使用类似下面的展开查询参数与日历关联。
https://graph.microsoft.com/v1.0/me/events/{事件ID}?$expand=Calendar
现在,您需要获取日历ID,然后使用下面显示的调用。
https://graph.microsoft.com/v1.0/me/calendars/{您获得的日历ID}
以获取日历的名称。
英文:
You can use the Calendar relationship with expand query parameter like below.
https://graph.microsoft.com/v1.0/me/events/{eventid}?$expand=Calendar
Now you need to get the Calendar id and later use the call shown below.
https://graph.microsoft.com/v1.0/me/calendars/{calendarid which you got}
to get the name of calendar.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论