POST and DELETE a booking using OutlookClient and Outlook Calendar API

為{幸葍}努か 提交于 2019-12-13 05:31:59

问题


I'm using Outlook-SDK-Android (MS) to talk with Outlook Calendar REST API.

So far I've been able to get the events from my calendar using:

        import com.microsoft.services.outlook.fetchers.OutlookClient;

        OutlookClient mClient;
        ...
        mClient = new OutlookClient(outlookBaseUrl, mResolver);

        final List<Event> events = mClient
            .getMe()
            //.getUsers()
            //.getById("meetingRoom@company.com") // This gives me back 403 :(
            .getCalendarView()
            .addParameter("startDateTime", startDate)
            .addParameter("endDateTime", endDate)
            .read()

(see here).

Question now is:

  • How can I use OutlookClient to add a booking?

( POST https://outlook.office.com/api/v2.0/me/calendars/{calendar_id}/events - from documentation)

  • What about deleting a calendar event instead?

( DELETE https://outlook.office.com/api/v2.0/me/events/{event_id} - from documentation )

Thanks


回答1:


Thanks to the hints received from one of the Outlook SDK Android authors (Marcos Torres - Microsoft Venezuela), it simply is:

Create event​:

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

Delete event​:

client.getMe().getEvents().getById(addedEvent.getId()).delete().get();

See e2e test.

Worth bear in mind though that "We're not maintaining the SDK anymore. By the way, by early April (Build Conference) a new SDK will be released. While may not be covering all the Outlook API surface now, it will be in the future."

And also "Keep in mind the SDK was code-generated from the endpoint-metadata. If by any chance the metadata (hence the service) change, the SDK won't work."



来源:https://stackoverflow.com/questions/35876015/post-and-delete-a-booking-using-outlookclient-and-outlook-calendar-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!