如何确定事件所在的日历?

huangapple go评论90阅读模式
英文:

How to determine which calendar an event is on?

问题

有没有一种简单的方法可以确定事件所属的日历?

例如,如果我有一个事件的ID,我可以这样做:

  1. Event event = graphClient
  2. .me()
  3. .events()
  4. .byId(eventId)
  5. .buildRequest(options)
  6. .get();

现在我有了这个事件,如何确定它属于哪个日历?事件中似乎有一个日历属性,所以我可以尝试做类似这样的事情:

  1. 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:

  1. Event event = graphClient
  2. .me()
  3. .events()
  4. .byId(eventId)
  5. .buildRequest(options)
  6. .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

  1. 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.

huangapple
  • 本文由 发表于 2020年10月10日 04:10:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/64286664.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定