/// <summary> /// Adds permissions to a OneDrive item /// </summary> /// <param name="itemPath">The path to the OneDrive item to add the permission to</param> /// <param name="requireSignin">Boolean to indicate if the user has to sign in before being able to access the OneDrive item</param> /// <param name="linkType">Indicates what type of access should be assigned to the invitees</param> /// <param name="emailAddresses">Array with e-mail addresses to receive access to the OneDrive item</param> /// <param name="sendInvitation">Send an e-mail to the invitees to inform them about having received permissions to the OneDrive item</param> /// <param name="sharingMessage">Custom message to add to the e-mail sent out to the invitees</param> /// <returns>Collection with OneDrivePermissionResponse objects representing the granted permissions</returns> public async Task <OneDriveCollectionResponse <OneDrivePermissionResponse> > AddPermission(string itemPath, bool requireSignin, bool sendInvitation, OneDriveLinkType linkType, string sharingMessage, string[] emailAddresses) { var permissionRequest = new OneDrivePermissionRequest { Message = sharingMessage, RequireSignin = requireSignin, SendInvitation = sendInvitation, Roles = linkType == OneDriveLinkType.View ? new[] { "read" } : new[] { "write" } }; var recipients = new List <OneDriveDriveRecipient>(); foreach (var emailAddress in emailAddresses) { recipients.Add(new OneDriveDriveRecipient { Email = emailAddress }); } permissionRequest.Recipients = recipients.ToArray(); return(await AddPermission(itemPath, permissionRequest)); }
/// <summary> /// Adds permissions to a OneDrive item /// </summary> /// <param name="itemPath">The path to the OneDrive item to add the permission to</param> /// <param name="permissionRequest">Details of the request for permission</param> /// <returns>Collection with OneDrivePermissionResponse objects representing the granted permissions</returns> public async Task <OneDriveCollectionResponse <OneDrivePermissionResponse> > AddPermission(string itemPath, OneDrivePermissionRequest permissionRequest) { var completeUrl = string.Concat(OneDriveApiBaseUrl, "drive/root:/", itemPath, ":/invite"); var result = await SendMessageReturnOneDriveItem <OneDriveCollectionResponse <OneDrivePermissionResponse> >(permissionRequest, HttpMethod.Post, completeUrl, HttpStatusCode.OK); return(result); }