/// <summary> /// Sends a HTTP POST to OneDrive to copy an item on OneDrive /// </summary> /// <param name="oneDriveSource">The OneDrive Item to be copied</param> /// <param name="oneDriveDestinationParent">The OneDrive parent item to copy the item into</param> /// <param name="destinationName">The name of the item at the destination where it will be copied to</param> /// <returns>True if successful, false if failed</returns> protected override async Task <bool> CopyItemInternal(OneDriveItem oneDriveSource, OneDriveItem oneDriveDestinationParent, string destinationName) { // Construct the complete URL to call var completeUrl = string.Concat(OneDriveApiBaseUrl, "drive/items/", oneDriveSource.Id, "/copy"); // Construct the OneDriveParentItemReference entity with the item to be copied details var requestBody = new OneDriveParentItemReference { ParentReference = new OneDriveItemReference { Id = oneDriveDestinationParent.Id }, Name = destinationName }; // Call the OneDrive webservice var result = await SendMessageReturnBool(requestBody, HttpMethod.Post, completeUrl, HttpStatusCode.Accepted, true); return(result); }
/// <summary> /// Sends a HTTP POST to OneDrive to copy an item on OneDrive /// </summary> /// <param name="oneDriveSource">The OneDrive Item to be copied</param> /// <param name="oneDriveDestinationParent">The OneDrive parent item to copy the item into</param> /// <param name="destinationName">The name of the item at the destination where it will be copied to</param> /// <returns>True if successful, false if failed</returns> protected override async Task <bool> CopyItemInternal(OneDriveItem oneDriveSource, OneDriveItem oneDriveDestinationParent, string destinationName) { // Construct the complete URL to call string completeUrl; if (oneDriveSource.RemoteItem != null) { // Item will be copied from another drive completeUrl = string.Concat("drives/", oneDriveSource.RemoteItem.ParentReference.DriveId, "/items/", oneDriveSource.RemoteItem.Id, "/copy"); } else if (!string.IsNullOrEmpty(oneDriveSource.ParentReference.DriveId)) { // Item will be coped from another drive completeUrl = string.Concat("drives/", oneDriveSource.ParentReference.DriveId, "/items/", oneDriveSource.Id, "/copy"); } else { // Item will be copied frp, the current user its drive completeUrl = string.Concat("drive/items/", oneDriveSource.Id, "/copy"); } // Construct the OneDriveParentItemReference entity with the item to be copied details var requestBody = new OneDriveParentItemReference { ParentReference = new OneDriveItemReference { Id = oneDriveDestinationParent.Id }, Name = destinationName }; // Call the OneDrive webservice var result = await SendMessageReturnBool(requestBody, HttpMethod.Post, completeUrl, HttpStatusCode.Accepted, true); return(result); }