使用Microsoft Graph在Microsoft日历中创建事件

时间:2019-06-11 06:45:01

标签: android microsoft-graph outlook-calendar

我正在使用此Microsoft Graph Tutorial通过Android Studio查看Microsoft日历事件。我已经完成了本教程,并且想知道如何创建事件。

我当前正在尝试使用Event对象创建事件。我正在尝试使用this GitHub repo中的以下代码:

Event event = new Event();
event.setSubject("Today's appointment");
event.setStart(dtz);
event.setImportance(Importance.High);
event.setIsReminderOn(true);
event.setReminderMinutesBeforeStart(15);

为此代码创建事件:

Event addedEvent = client.getMe().getCalendars().getById("Calendar").getEvents().add(event).get();

但是似乎set函数不再可用,因此我找不到任何其他教程/资源。任何帮助将不胜感激。

谢谢。

1 个答案:

答案 0 :(得分:0)

您用于寻求帮助的github存储库未使用找到的here Java Graph SDK。但是,如果您在android示例的基础上构建解决方案,则下面的代码示例应该可以帮助您创建事件您是第一次使用。

基本上,sdk中的模型具有可以通过分配直接修改的属性,我们使用post(event)通过POST http方法将其发送过来。

Event event = new Event();
event.subject = "Let's go for lunch";
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "Does late morning work for you?";
event.body = body;
DateTimeTimeZone start = new DateTimeTimeZone();
start.dateTime = "2017-04-15T12:00:00";
start.timeZone = "Pacific Standard Time";
event.start = start;
DateTimeTimeZone end = new DateTimeTimeZone();
end.dateTime = "2017-04-15T14:00:00";
end.timeZone = "Pacific Standard Time";
event.end = end;
Location location = new Location();
location.displayName = "Harry's Bar";
event.location = location;

graphClient.me().events()
    .buildRequest()
    .post(event);

此github存储库也可能是一个很好的帮助,因为它具有许多很棒的摘要:) https://github.com/microsoftgraph/android-java-snippets-sample

相关问题