有没有办法知道在使用Graph API查询日历事件时可以使用哪些选项和属性?

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

Is there a way to know what options and properties are available to use when querying for calendar events with the Graph API?

问题

这可能是一个愚蠢的问题,但是在尝试使用微软的 Java Graph API 查询日历事件时,我有些困惑,不知道有哪些可用的选项。

在他们的教程中,他们有以下代码示例。

public static List<Event> getEvents(String accessToken) {
    ensureGraphClient(accessToken);

    // 使用 QueryOption 来指定 $orderby 查询参数
    final List<Option> options = new LinkedList<Option>();
    // 按 createdDateTime 排序,获取最新的事件
    options.add(new QueryOption("orderby", "createdDateTime DESC"));

    // GET /me/events
    IEventCollectionPage eventPage = graphClient
        .me()
        .events()
        .buildRequest(options)
        .select("subject,organizer,start,end")
        .get();

    return eventPage.getCurrentPage();
}

他们在使用 orderby 选项,并告诉它使用 createdDateTime 降序排序。是否有其他选项及其可能的取值列表呢?例如,如果我只想要从2020年10月1日到2020年10月31日的事件,我应该使用哪个选项?

我的第二个问题与他们选择的属性有关(subject,organizer,start,end)。是否还有一个可供每个事件选择的可能属性列表呢?

英文:

This may be a dumb question, but I'm kind of stuck when trying to figure out what options I have available when querying for calendar events using Microsoft's Java Graph API.

In their tutorial they have the following code example.

public static List&lt;Event&gt; getEvents(String accessToken) {
    ensureGraphClient(accessToken);

    // Use QueryOption to specify the $orderby query parameter
    final List&lt;Option&gt; options = new LinkedList&lt;Option&gt;();
    // Sort results by createdDateTime, get newest first
    options.add(new QueryOption(&quot;orderby&quot;, &quot;createdDateTime DESC&quot;));

    // GET /me/events
    IEventCollectionPage eventPage = graphClient
        .me()
        .events()
        .buildRequest(options)
        .select(&quot;subject,organizer,start,end&quot;)
        .get();

    return eventPage.getCurrentPage();
}

They are using the orderby option and telling it to use createdDateTime DESC ordering. Is there a list of other options and their possible values somewhere? For example, what option would I use if I only wanted events from 2020-10-01 to 2020-10-31?

My second question is regarding the properties that they're selecting (subject, organizer, start, end). Is there also a list of possible properties that can be selected for each event?

答案1

得分: 1

你可以在事件资源类型中查看所有属性。你可以在这里查看ODATA查询选项。你可以使用过滤查询参数来过滤数据。但要记住,并非所有属性/终端都支持这些选项。

英文:

You can see all the properties in the event resource type. You can see the ODATA query options here. You can use filter query parameter that can filter the data. But remember that some properties/endpoints support them and some may not.

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

发表评论

匿名网友

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

确定