POST and DELETE a booking using OutlookClient and Outlook Calendar API
Asked Answered
R

1

0

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("[email protected]") // 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

Rift answered 8/3, 2016 at 19:13 Comment(0)
R
0

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

Rift answered 10/3, 2016 at 0:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.