/// <summary> /// This method updated an existing user in Azure AD /// </summary> /// <param name="user">The user's fields to update</param> public static void UpdateUser(User user) { MicrosoftGraphHelper.MakePatchRequestForString( String.Format("{0}users/{1}", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, user.Id), user, "application/json"); }
/// <summary> /// Updates the photo of an Office 365 Group /// </summary> /// <param name="groupId">The ID of the target group</param> /// <param name="photo">The byte array of the photo</param> public static void UpdateUnifiedGroupPhoto(String groupId, Stream photo) { MicrosoftGraphHelper.MakePatchRequestForString( String.Format("{0}groups/{1}/photo/$value", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, groupId), photo, "image/jpeg"); }
/// <summary> /// This method updates an event in a calendar /// </summary> /// <param name="calendarId">The ID of the calendar</param> /// <param name="eventId">The event to update</param> /// <returns>The updated event</returns> public static Event UpdateEvent(String calendarId, Event eventToUpdate) { String jsonResponse = MicrosoftGraphHelper.MakePatchRequestForString( String.Format("{0}me/calendars/{1}/events/{2}", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, calendarId, eventToUpdate.Id), eventToUpdate, "application/json"); var updatedEvent = JsonConvert.DeserializeObject <Event>(jsonResponse); return(updatedEvent); }
/// <summary> /// This method updates a contact /// </summary> /// <param name="contact">The contact to update</param> /// <returns>The updated contact</returns> public static Contact UpdateContact(Contact contact) { String jsonResponse = MicrosoftGraphHelper.MakePatchRequestForString( String.Format("{0}me/contacts/{1}", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, contact.Id), contact, "application/json"); var updatedContact = JsonConvert.DeserializeObject <Contact>(jsonResponse); return(updatedContact); }
/// <summary> /// This method renames an already existing file in OneDrive for Business /// </summary> /// <param name="driveId">The ID of the target drive</param> /// <param name="fileId">The ID of the target file</param> /// <param name="newFileName">The new file name</param> /// <returns>The updated DriveItem corresponding to the renamed file</returns> public static DriveItem RenameFile(String driveId, String fileId, String newFileName) { var jsonResponse = MicrosoftGraphHelper.MakePatchRequestForString( String.Format("{0}drives/{1}/items/{2}", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, driveId, fileId), new DriveItem { Name = newFileName, }, "application/json"); var updatedFile = JsonConvert.DeserializeObject <DriveItem>(jsonResponse); return(updatedFile); }
/// <summary> /// This method moves one item from one parent folder to another /// </summary> /// <param name="driveId">The ID of the target drive</param> /// <param name="driveItemId">The ID of the target file</param> /// <param name="newItemName">The new name for the item in the target folder</param> /// <param name="newParent">The name of the new target folder</param> /// <returns>The moved DriveItem instance</returns> public static DriveItem MoveDriveItem(String driveId, String driveItemId, String newItemName, String newParent) { var jsonResponse = MicrosoftGraphHelper.MakePatchRequestForString( String.Format("{0}drives/{1}/items/{2}", MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, driveId, driveItemId), new DriveItem { Name = newItemName, ParentReference = new ItemReference { Path = $"/drive/root:/{newParent}" } }, "application/json"); var movedItem = JsonConvert.DeserializeObject <DriveItem>(jsonResponse); return(movedItem); }