/// <summary> /// Send an httpRequest to get an One drive Item /// </summary> /// <param name="provider">OneDriveClient Provider</param> /// <param name="request">Http Request to execute</param> /// <param name="destinationFolder">Destination folder</param> /// <param name="desiredNewName">New name</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>a OneDrive item or null if the request fail</returns> internal static async Task <bool> MoveAsync(this IGraphServiceClient provider, HttpRequestMessage request, OneDriveStorageFolder destinationFolder, string desiredNewName, CancellationToken cancellationToken) { OneDriveParentReference rootParentReference = new OneDriveParentReference(); if (destinationFolder.OneDriveItem.Name == "root") { rootParentReference.Parent.Path = "/drive/root:/"; } else { rootParentReference.Parent.Path = destinationFolder.OneDriveItem.ParentReference.Path + $"/{destinationFolder.OneDriveItem.Name}"; } rootParentReference.Name = desiredNewName; var content = JsonConvert.SerializeObject(rootParentReference); request.Content = new StringContent(content, Encoding.UTF8, "application/json"); await provider.AuthenticationProvider.AuthenticateRequestAsync(request).ConfigureAwait(false); var response = await provider.HttpProvider.SendAsync(request, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false); return(response.IsSuccessStatusCode); }