问题
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