The MSGraphAPI class serves as a primary point of interaction for working with Microsoft Graph API, providing easy access to various services like users, calendar, meeting rooms, and places.
me: An instance of theMeclass for user-specific operations.users: An instance of theUsersclass for operations related to all users.calendar: An instance of theCalendarclass for calendar-related operations.meetingRooms: An instance of theMeetingRoomsclass for operations related to meeting rooms.place: An instance of thePlaceclass for place-related operations.notes: An instance of theNotesclass for notes-related operations.contacts: An instance of theContactsclass for contacts-related operations.mail: An instance of theMailclass for email-related operations.group: An instance of theGroupAPIclass for Microsoft 365 Groups operations.drive: An instance of theDriveAPIclass for OneDrive files and folders operations.planner: An instance of thePlannerAPIclass for Microsoft Planner operations.todo: An instance of theTodoAPIclass for Microsoft To Do operations.
The constructor takes a string parameter, _token, which represents the authentication token for accessing Microsoft Graph API. It initializes instances of Me, Users, Calendar, MeetingRooms, Place, Notes, Contacts, Mail, Group, Drive, Planner, and Todo classes.
String token = 'Your Microsoft Graph API token here';
MSGraphAPI graphAPI = MSGraphAPI(token);
// Use the instances
User userInfo = graphAPI.me.fetchUserInfo();
List<Room> allPlaceRooms = graphAPI.place.fetchAllRooms();Todo
The getTaskLists method retrieves all To Do task lists for the current user.
List<TodoTaskList> taskLists = await graphAPI.todo.getTaskLists();The getTaskList method retrieves a specific task list by its ID.
TodoTaskList taskList = await graphAPI.todo.getTaskList(taskListId);The createTaskList method creates a new task list.
TodoTaskListCreateRequest request = TodoTaskListCreateRequest(
displayName: 'My New Tasks',
);
TodoTaskList newTaskList = await graphAPI.todo.createTaskList(request);The updateTaskList method updates an existing task list.
TodoTaskListUpdateRequest request = TodoTaskListUpdateRequest(
displayName: 'Updated Task List Name',
);
TodoTaskList updatedTaskList = await graphAPI.todo.updateTaskList(taskListId, request);The deleteTaskList method deletes a task list.
bool success = await graphAPI.todo.deleteTaskList(taskListId);The getTasks method retrieves all tasks in a specific task list.
List<TodoTask> tasks = await graphAPI.todo.getTasks(taskListId);The getTask method retrieves a specific task by its ID.
TodoTask task = await graphAPI.todo.getTask(taskListId, taskId);The createTask method creates a new task in a task list.
TodoTaskCreateRequest request = TodoTaskCreateRequest(
title: 'Complete documentation',
dueDateTime: DateTime.now().add(Duration(days: 1)),
);
TodoTask newTask = await graphAPI.todo.createTask(taskListId, request);The updateTask method updates an existing task.
TodoTaskUpdateRequest request = TodoTaskUpdateRequest(
title: 'Updated task title',
importance: 'high',
);
TodoTask updatedTask = await graphAPI.todo.updateTask(taskListId, taskId, request);The deleteTask method deletes a task.
bool success = await graphAPI.todo.deleteTask(taskListId, taskId);The completeTask method marks a task as completed.
TodoTask completedTask = await graphAPI.todo.completeTask(taskListId, taskId);The getLinkedResources method retrieves all linked resources for a task.
List<LinkedResource> resources = await graphAPI.todo.getLinkedResources(taskListId, taskId);The createLinkedResource method creates a new linked resource for a task.
LinkedResourceCreateRequest request = LinkedResourceCreateRequest(
webUrl: 'https://example.com/resource',
applicationName: 'Browser',
displayName: 'Example Resource',
);
LinkedResource newResource = await graphAPI.todo.createLinkedResource(taskListId, taskId, request);The deleteLinkedResource method deletes a linked resource from a task.
bool success = await graphAPI.todo.deleteLinkedResource(taskListId, taskId, linkedResourceId);Me
The fetchUserInfo method is used to fetch the user's information from the Microsoft Graph API. The method sends a GET request and does not require any parameters. It returns a Future<User> object that represents the user's information.
User user = await graphAPI.me.fetchUserInfo();The changePassword method is used to change the user's password. It requires two parameters: currentPassword and newPassword, which represent the current and new passwords, respectively. The method sends a PATCH request to the Microsoft Graph API and returns a Future<bool> indicating the success of the operation.
bool isChanged = await graphAPI.me.changePassword(currentPassword, newPassword);The fetchUserProfileImage method is used to fetch the user's profile image from the Microsoft Graph API. The method sends a GET request and requires a size parameter, which specifies the desired size of the image. It returns a Future<Uint8List> object representing the user's profile image as bytes. If calling from Flutter, you can wrap the image in an ImageProvider such as MemoryImage.
Uint8List image = await graphAPI.me.fetchUserProfileImage(size);The fetchTimeZones method fetches a list of time zones supported by the Microsoft Graph API. This function is asynchronous and returns a list of TimeZone objects.
The function sends a GET request to the Microsoft Graph API.
If the request is successful (HTTP status code 200), the function transforms the 'value' field from the response data into a list of TimeZone objects, which contains the time zones, and returns this list.
In case of an error (e.g., network error, invalid response data, etc.), the function throws an exception with an appropriate error message.
List<TimeZone> timeZones = await graphAPI.me.fetchTimeZones();The fetchOneNoteNotebooks` method is designed to retrieve all OneNote notebooks associated with the authenticated user from the Microsoft Graph API. It carries out a GET request for these notebooks. An authorization header with the bearer token is essential for this request. If the request concludes successfully, it returns a list of notebooks. In the event of an error during the request, an error message is logged.
List<Map<String, dynamic>> notebooks = await fetchOneNoteNotebooks();The createOneNoteNotebook method is tailored to establish a new OneNote notebook for the authenticated user via the Microsoft Graph API. It conducts a POST request to generate the notebook, specifying its name. An authorization header, accompanied by the bearer token, is pivotal for this request. If the request culminates successfully, the method yields the created notebook, encapsulating its attributes in a map. Conversely, if any complications arise during the request, an error message is duly logged.
Map<String, dynamic> newNotebook = await createOneNoteNotebook("My New Notebook");Users
The fetchSpecificUserInfo method is used to fetch the user's information for a specific user from the Microsoft Graph API. The method sends a GET request and requires the userId parameter. It returns a Future<User> object that represents the user's information.
User user = await graphAPI.users.fetchSpecificUserInfo(userId);The createUser method is used to create a new user. It requires four parameters: displayName, mailNickname, userPrincipalName, and password. The method sends a POST request to the Microsoft Graph API and returns a Future<User> object representing the newly created user.
User newUser = await Users.createUser(displayName, mailNickname, userPrincipalName, password);The deleteUser method is used to delete a user. It requires the userId parameter and sends a DELETE request to the Microsoft Graph API. It returns a Future` indicating the success of the deletion operation.
bool success = await Users.deleteUser(userId);The fetchOneNoteNotebooksForUser method aims to obtain OneNote notebooks associated with a specific user, identified by their ID or userPrincipalName, from the Microsoft Graph API. This method executes a GET request for the notebooks of the specified user. The request mandates an authorization header with the bearer token. When the request is successful, it yields a list of notebooks for that user. If any error arises during the request, an error message is logged.
List<Map<String, dynamic>> userNotebooks = await fetchOneNoteNotebooksForUser(userIdOrPrincipal);The createOneNoteNotebookForUser method is devised to fabricate a new OneNote notebook for a distinct user, discerned by their ID or userPrincipalName, through the Microsoft Graph API. This method initiates a POST request to engender the notebook for the designated user, denoting its name. The request is contingent on an authorization header with the bearer token. Upon a successful request, the method proffers the freshly created notebook, representing its properties in a map. Should there be any disruptions during the request, an error message is chronicled.
Map<String, dynamic> userSpecificNotebook = await createOneNoteNotebookForUser(userIdOrPrincipal, "User's Private Notebook");The fetchAllUserRooms method is used to fetch all user rooms. This method sends a GET request to the 'findRooms' endpoint of the Microsoft Graph API and converts the response data into a list of 'Room' objects. It returns a Future<List>` representing all the rooms fetched by the user.
List<Room> rooms = await Users.fetchAllUserRooms();Calendar
The fetchCalendarEventsForRange method is used to fetch calendar events within a specific date range. The method sends a GET request and requires the startDateTime and endDateTime parameters. It returns a Future<List<CalendarEvent>> object that represents the calendar events within the given date range.
List<CalendarEvent> events = await Calendar.fetchCalendarEventsForRange(startDateTime, endDateTime);The createCalendarEvent method is used to create a calendar event via the Microsoft Graph API. It performs a POST request to create the calendar event. The request requires an authorization header with the bearer token. This method accepts a range of optional parameters representing various attributes of the event to be created.
The parameters include id, createdDateTime, lastModifiedDateTime, isReminderOn, subject, bodyPreview, isAllDay, isOrganizer, startDateTime, endDateTime, a list of attendees, and organizer.
If a parameter is provided, it's included in the data sent in the request. If attendees or organizer are provided, they're converted to JSON before being included in the request data.
The function tries to create a calendar event and returns a Future that completes with a CalendarEvent if the request was successful. If an error occurs during the request, an error message is logged and the error is rethrown.
await Calendar.createCalendarEvent(
id: 'event1',
createdDateTime: '2023-06-21T10:00:00.000Z',
lastModifiedDateTime: '2023-06-21T10:00:00.000Z',
isReminderOn: true,
subject: 'Important Meeting',
bodyPreview: 'Discussing project status',
isAllDay: false,
isOrganizer: true,
startDateTime: '2023-06-22T10:00:00.000Z',
endDateTime: '2023-06-22T12:00:00.000Z',
attendees: [Attendee(name: 'John Doe', email: 'johndoe@example.com')],
organizer: Organizer(name: 'Jane Doe', email: 'janedoe@example.com')
);The fetchCalendars method is used to fetch calendar objects from the Microsoft Graph API. It performs a GET request to obtain the calendars. The request requires an authorization header with the bearer token. This method accepts one optional parameter userId to specify whose calendars to fetch. If userId is not provided, the calendars of the current user will be fetched.
The function attempts to fetch the calendars and returns a Future that completes with a list of Calendar objects if the request was successful. If an error occurs during the request, it prints an error message and rethrows the error.
List<Calendar> myCalendars = await Calendar.fetchCalendars();
List<Calendar> usersCalendars = await Calendar.fetchCalendars(userId: 'UserId here');The findMeetingTimes method is used to suggest meeting times based on availability data from the Microsoft Graph API. It performs a POST request to fetch the suggested meeting times. The request requires an authorization header with the bearer token. This method accepts optional parameters including userId, attendees, timeSlots, locationConstraint, and meetingDuration.
The parameters work as follows:
userId: The ID of the user for whom to find meeting times. If not provided, the current user is assumed.
attendees: A list of attendees for the meeting.
timeSlots: A list of available time slots for the meeting.
locationConstraint: The constraints on the location of the meeting.
meetingDuration: The duration of the meeting.
The function creates a map from the provided parameters, converts it to JSON, and includes it in the body of the POST request. It then attempts to fetch the meeting time suggestions and returns a Future that completes with a MeetingTimeSuggestionsResult` object if the request was successful. If an error occurs during the request, it prints an error message and rethrows the error.
MeetingTimeSuggestionsResult otherUsersMeetingTimes = await Calendar.findMeetingTimes(
userId: 'user1',
attendees: [Attendee(name: 'John Doe', email: 'johndoe@example.com')],
timeSlots: [TimeSlot(start: '2023-06-22T09:00:00.000Z', end: '2023-06-22T18:00:00.000Z')],
locationConstraint: LocationConstraint(isRequired: false, suggestLocation: false),
meetingDuration: 'PT1H' //The length of the meeting, denoted in ISO8601 format. For example, 1 hour is denoted as 'PT1H', where 'P' is the duration designator, 'T' is the time designator, and 'H' is the hour designator. Use M to indicate minutes for the duration; for example, 2 hours and 30 minutes would be 'PT2H30M'. If no meeting duration is specified, findMeetingTimes uses the default of 30 minutes.
);
MeetingTimeSuggestionsResult myMeetingTimes = await Calendar.findMeetingTimes(
attendees: [Attendee(name: 'John Doe', email: 'johndoe@example.com')],
timeSlots: [TimeSlot(start: '2023-06-22T09:00:00.000Z', end: '2023-06-22T18:00:00.000Z')],
locationConstraint: LocationConstraint(isRequired: false, suggestLocation: false),
meetingDuration: 'PT1H' //The length of the meeting, denoted in ISO8601 format. For example, 1 hour is denoted as 'PT1H', where 'P' is the duration designator, 'T' is the time designator, and 'H' is the hour designator. Use M to indicate minutes for the duration; for example, 2 hours and 30 minutes would be 'PT2H30M'. If no meeting duration is specified, findMeetingTimes uses the default of 30 minutes.
);The `getFreeBusySchedule method fetches the free/busy schedule of specific users from the Microsoft Graph API within a given date-time range.
This function is asynchronous and returns a ScheduleResponse object. It takes in four parameters:
-
startTime: The start date-time in ISO format to define the range for which to fetch the schedule. -
endTime: The end date-time in ISO format to define the range for which to fetch the schedule. -
userId(optional): The ID of the user for whom to fetch the schedule. If not provided, the function fetches the schedule for the currently authenticated user. -
timeZone(optional): The time zone in which to return the schedule. If not provided, the function uses 'W. Europe Standard Time' as the default time zone. -
The function sends a POST request to the Microsoft Graph API. The requested URL includes the user ID (if provided), and the request body includes the start and end times, the time zone, and an availability view interval of 60 minutes.
If the request is successful, the function transforms the response data into a ScheduleResponse object and returns this object.
In case of an error (e.g., network error, invalid response data, etc.), the function catches the exception, logs an appropriate error message, and rethrows the exception.
ScheduleResponse schedule = getFreeBusySchedule(
'2023-06-21T10:00:00',
'2023-06-21T16:00:00',
'userID',
TimeZone('W. Europe Standard Time'),
);MeetingRooms
The bookMeetingRoom method is used to book a meeting room by creating a new event. It requires a CalendarEvent parameter representing the event to be created. This event should represent the booking of the meeting room. The method sends a POST request to the Microsoft Graph API. If the request is successful, it logs a success message. If the request fails, it logs the error message.
await MeetingRooms.bookMeetingRoom(CalendarEvent event);Place
The fetchAllRooms method is used to fetch all the rooms from the Microsoft Graph API. It performs a GET request for the rooms. The request requires an authorization header with the bearer token. If the request is successful, it logs the rooms. If there's an error during the request, it logs an error message.
List<Room> rooms = Place.fetchAllRooms();The fetchAllRoomLists method is used to fetch all the room lists from the Microsoft Graph API. It performs a GET request for the room lists. The request requires an authorization header with the bearer token. If the request is successful, it logs the room lists. If there's an error during the request, it logs an error message.
List<Room> rooms = Place.fetchAllRooms();Notes
The fetchOneNoteNotebooks` method is designed to retrieve all OneNote notebooks associated with the authenticated user from the Microsoft Graph API. It carries out a GET request for these notebooks. An authorization header with the bearer token is essential for this request. If the request concludes successfully, it returns a list of notebooks. In the event of an error during the request, an error message is logged.
List<Map<String, dynamic>> notebooks = await fetchOneNoteNotebooks();The createOneNoteNotebook method is tailored to establish a new OneNote notebook for the authenticated user via the Microsoft Graph API. It conducts a POST request to generate the notebook, specifying its name. An authorization header, accompanied by the bearer token, is pivotal for this request. If the request culminates successfully, the method yields the created notebook, encapsulating its attributes in a map. Conversely, if any complications arise during the request, an error message is duly logged.
Map<String, dynamic> newNotebook = await createOneNoteNotebook("My New Notebook");The fetchOneNoteNotebooksForUser method aims to obtain OneNote notebooks associated with a specific user, identified by their ID or userPrincipalName, from the Microsoft Graph API. This method executes a GET request for the notebooks of the specified user. The request mandates an authorization header with the bearer token. When the request is successful, it yields a list of notebooks for that user. If any error arises during the request, an error message is logged.
List<Map<String, dynamic>> userNotebooks = await fetchOneNoteNotebooksForUser(userIdOrPrincipal);The createOneNoteNotebookForUser method is devised to fabricate a new OneNote notebook for a distinct user, discerned by their ID or userPrincipalName, through the Microsoft Graph API. This method initiates a POST request to engender the notebook for the designated user, denoting its name. The request is contingent on an authorization header with the bearer token. Upon a successful request, the method proffers the freshly created notebook, representing its properties in a map. Should there be any disruptions during the request, an error message is chronicled.
Map<String, dynamic> userSpecificNotebook = await createOneNoteNotebookForUser(userIdOrPrincipal, "User's Private Notebook");Contacts
The listContacts method is used to fetch contacts from the Microsoft Graph API. It performs a GET request for the contacts. The request requires an authorization header with the bearer token. If the request is successful, it logs the contacts. If there's an error during the request, it logs an error message.
It takes an optional folderId parameter, which specifies the ID of the folder from which to fetch the contacts. If not provided, the contacts are fetched from the default contacts folder.
Paging is internally handled by the method.
It also takes an optional query parameter, which specifies the query string to filter the contacts. If not provided, all contacts are fetched.
List<Contact> contacts = await Contacts.listContacts();The listContactFolders method is used to fetch contact folders from the Microsoft Graph API. It performs a GET request for the contact folders. The request requires an authorization header with the bearer token. If the request is successful, it logs the contact folders. If there's an error during the request, it logs an error message.
List<ContactFolder> contactFolders = await Contacts.listContactFolders();By default, the mail methods run against the user authorised by the token. Each of the mail methods can take an optional username/id to specify which user to run the actions as.
The getMailFolders method fetches all mail folders from the Microsoft Graph API. It returns a list of MailFolder objects.
List<MailFolder> folders = await graphAPI.mail.getMailFolders();or to fetch the folders for a specific user:
List<MailFolder> folders = await graphAPI.mail.getMailFolders(userIdOrPrincipal: 'someuser@outlook.com');The getMessages method retrieves emails from a specified folder or from the inbox if no folder is specified. This method supports filtering and pagination.
// Get messages from inbox
List<Message> messages = await graphAPI.mail.getMessages();
// Get messages from inbox for a specific user (with appropriate permissions)
List<Message> messages = await graphAPI.mail.getMessages(userIdOrPrincipal: 'someuser@outlook.com');
// Get messages from a specific folder
List<Message> messages = await graphAPI.mail.getMessages(folderId: 'folderIdHere');
// Get filtered messages
List<Message> messages = await graphAPI.mail.getMessages(filter: 'isRead eq false');The sendMail method sends a new email message.
MessageCreateRequest newMessage = MessageCreateRequest(
subject: 'Test Subject',
body: ItemBody(
contentType: 'HTML',
content: '<p>This is a test email body.</p>',
),
toRecipients: [
Recipient(
emailAddress: EmailAddress(
name: 'John Doe',
address: 'johndoe@example.com',
),
),
],
);
bool success = await graphAPI.mail.sendMail(newMessage);The createDraft method creates a draft message that can be edited or sent later.
Message draft = await graphAPI.mail.createDraft(messageRequest);The searchMessages method allows searching for messages that match a query string.
List<Message> results = await graphAPI.mail.searchMessages('important meeting');Get attachments for a message:
List<Attachment> attachments = await graphAPI.mail.getAttachments(messageId);Add an attachment to a message:
Attachment attachment = await graphAPI.mail.addAttachment(
messageId,
'file.txt',
base64Content,
'text/plain'
);The Mail API also provides methods for moving messages, setting flags, updating message properties, and more. Some examples:
// Mark a message as read/unread
await graphAPI.mail.markAsRead(messageId, true);
// Move a message to a different folder
Message movedMessage = await graphAPI.mail.moveMessage(messageId, targetFolderId);
// Set a flag on a message
await graphAPI.mail.setFlag(messageId, 'flagged');
// Delete a message
bool deleted = await graphAPI.mail.deleteMessage(messageId);Groups
The getGroups method fetches all Microsoft 365 groups the authenticated user is a member of.
List<Group> groups = await graphAPI.group.getGroups();The getGroup method retrieves a specific group by its ID.
Group group = await graphAPI.group.getGroup(groupId);The createGroup method creates a new Microsoft 365 group.
GroupCreateRequest request = GroupCreateRequest(
displayName: 'Marketing Team',
mailNickname: 'marketing',
description: 'Group for marketing team collaboration',
mailEnabled: true,
securityEnabled: false,
groupTypes: ['Unified']
);
Group newGroup = await graphAPI.group.createGroup(request);The Group API provides methods for updating and deleting groups:
// Update a group's properties
bool updated = await graphAPI.group.updateGroup(groupId, {
'description': 'Updated description for the marketing team'
});
// Delete a group
bool deleted = await graphAPI.group.deleteGroup(groupId);Manage members of a group with these methods:
// Get all members of a group
List<GroupMember> members = await graphAPI.group.getGroupMembers(groupId);
// Add a member to a group
bool added = await graphAPI.group.addGroupMember(groupId, userId);
// Remove a member from a group
bool removed = await graphAPI.group.removeGroupMember(groupId, userId);Work with group conversations, threads, and posts:
// Get conversations in a group
List<GroupConversation> conversations = await graphAPI.group.getGroupConversations(groupId);
// Create a new conversation
ConversationCreateRequest convRequest = ConversationCreateRequest(
topic: 'Project Discussion',
message: '<p>Let\'s discuss the new project timeline.</p>'
);
GroupConversation newConversation = await graphAPI.group.createGroupConversation(
groupId,
convRequest
);
// Get threads in a conversation
List<ConversationThread> threads = await graphAPI.group.getConversationThreads(
groupId,
conversationId
);
// Get posts in a thread
List<Post> posts = await graphAPI.group.getThreadPosts(
groupId,
conversationId,
threadId
);
// Create a post in a thread
PostCreateRequest postRequest = PostCreateRequest(
body: ItemBody(
contentType: 'HTML',
content: '<p>I agree with the proposed timeline.</p>'
)
);
Post newPost = await graphAPI.group.createPost(
groupId,
conversationId,
threadId,
postRequest
);Manage group lifecycle policies with these methods:
// Get all lifecycle policies
List<GroupLifecyclePolicy> policies = await graphAPI.group.getGroupLifecyclePolicies();
// Add a policy to a group
bool added = await graphAPI.group.addLifecyclePolicyToGroup(groupId, policyId);
// Remove a policy from a group
bool removed = await graphAPI.group.removeLifecyclePolicyFromGroup(groupId, policyId);OneDrive/Files
The getDrives method fetches all available drives for the authenticated user.
List<Drive> drives = await graphAPI.drive.getDrives();The getDefaultDrive method retrieves information about the authenticated user's default drive.
Drive drive = await graphAPI.drive.getDefaultDrive();The listItems method retrieves files and folders within a specified folder.
// List items in the root folder of default drive
List<DriveItem> items = await graphAPI.drive.listItems();
// List items in a specific folder
List<DriveItem> folderItems = await graphAPI.drive.listItems(folderId: 'folderId');
// List items in a specific drive
List<DriveItem> driveItems = await graphAPI.drive.listItems(driveId: 'driveId');Retrieve a specific file or folder by its ID or path:
// Get by ID
DriveItem item = await graphAPI.drive.getItem('itemId');
// Get by path
DriveItem documentItem = await graphAPI.drive.getItemByPath('/Documents/Report.docx');The createFolder method creates a new folder in the specified location:
DriveItem newFolder = await graphAPI.drive.createFolder(
'Projects',
parentFolderId: 'folderId', // 'root' is default
);Upload small files (less than 4MB):
DriveItem uploadedFile = await graphAPI.drive.uploadSmallFile(
'document.txt',
fileContent, // Uint8List of file content
contentType: 'text/plain'
);For larger files, create an upload session:
UploadSession session = await graphAPI.drive.createUploadSession(
'large-video.mp4',
parentFolderId: 'folderId'
);
// Use the uploadUrl property from the session to upload the file in chunksThe downloadFile method downloads a file's content:
Uint8List fileContent = await graphAPI.drive.downloadFile('fileId');Move files and folders:
DriveItem movedItem = await graphAPI.drive.moveItem(
'itemId',
'newParentFolderId',
newName: 'newFileName.txt' // Optional rename during move
);Copy files and folders:
bool copyStarted = await graphAPI.drive.copyItem(
'itemId',
'destinationFolderId'
);Delete files or folders:
bool deleted = await graphAPI.drive.deleteItem('itemId');Search for files and folders across a drive:
List<DriveItem> searchResults = await graphAPI.drive.searchItems('project proposal');Retrieve thumbnails for image files:
ThumbnailSet thumbnails = await graphAPI.drive.getThumbnails('imageFileId');
// Access specific sizes
String smallThumbnailUrl = thumbnails.small.url;
String mediumThumbnailUrl = thumbnails.medium.url;
String largeThumbnailUrl = thumbnails.large.url;Planner
The getPlans method fetches all plans the authenticated user has access to.
List<Plan> plans = await graphAPI.planner.getPlans();The getGroupPlans method fetches all plans for a specific Microsoft 365 Group.
List<Plan> groupPlans = await graphAPI.planner.getGroupPlans('groupId');Retrieve details about a specific plan:
Plan plan = await graphAPI.planner.getPlan('planId');
PlanDetails details = await graphAPI.planner.getPlanDetails('planId');Create a new plan in a Microsoft 365 Group:
PlanCreateRequest request = PlanCreateRequest(
title: 'Q4 Project Plan',
owner: 'groupId' // ID of the Microsoft 365 Group
);
Plan newPlan = await graphAPI.planner.createPlan(request);Update an existing plan (requires ETag for concurrency control):
PlanUpdateRequest updateRequest = PlanUpdateRequest(
title: 'Updated Plan Title'
);
Plan updatedPlan = await graphAPI.planner.updatePlan(
'planId',
updateRequest,
'plan-etag-value'
);Get all tasks in a plan:
List<PlannerTask> tasks = await graphAPI.planner.getPlanTasks('planId');Get a specific task and its details:
PlannerTask task = await graphAPI.planner.getTask('taskId');
PlannerTaskDetails taskDetails = await graphAPI.planner.getTaskDetails('taskId');Create a new task in a plan:
TaskCreateRequest taskRequest = TaskCreateRequest(
title: 'Complete API integration',
planId: 'planId',
bucketId: 'bucketId', // The bucket/column the task belongs to
dueDateTime: '2023-12-15T17:00:00Z',
priority: 5 // 0-10, higher means higher priority
);
PlannerTask newTask = await graphAPI.planner.createTask(taskRequest);Update a task (requires ETag for concurrency control):
TaskUpdateRequest updateRequest = TaskUpdateRequest(
title: 'Updated task title',
percentComplete: 50,
priority: 8
);
PlannerTask updatedTask = await graphAPI.planner.updateTask(
'taskId',
updateRequest,
'task-etag-value'
);Assign a task to a user:
bool assigned = await graphAPI.planner.assignTask(
'taskId',
'userId',
'task-etag-value'
);Delete a task:
bool deleted = await graphAPI.planner.deleteTask('taskId', 'task-etag-value');Get all buckets in a plan:
List<PlannerBucket> buckets = await graphAPI.planner.getPlanBuckets('planId');Create a new bucket:
BucketCreateRequest bucketRequest = BucketCreateRequest(
name: 'In Progress',
planId: 'planId'
);
PlannerBucket newBucket = await graphAPI.planner.createBucket(bucketRequest);Update a bucket:
BucketUpdateRequest updateRequest = BucketUpdateRequest(
name: 'Updated Bucket Name'
);
PlannerBucket updatedBucket = await graphAPI.planner.updateBucket(
'bucketId',
updateRequest,
'bucket-etag-value'
);Delete a bucket:
bool deleted = await graphAPI.planner.deleteBucket('bucketId', 'bucket-etag-value');Janik Kahle 💻 |
Noah Anderson 💻 |
Ben Hills 💻 |