我正在使用MS Graph .net SDK . 尝试将sharepoint文档库复制到另一个sharepoint文档库 .
如果文件大约为38mb,则会因未知错误而引发GatewayTimeout异常 .
MS有错误,或者我做错了什么 . 这是我的代码:
HttpRequestMessage hrm = new HttpRequestMessage(HttpMethod.Post, request.RequestUrl);
hrm.Content = new StringContent(JsonConvert.SerializeObject(request.RequestBody), System.Text.Encoding.UTF8, "application/json");
await client.AuthenticationProvider.AuthenticateRequestAsync(hrm);
HttpResponseMessage response = await client.HttpProvider.SendAsync(hrm);
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
}
}
catch (Microsoft.Graph.ServiceException ex)
{
throw new Exception("Unknown Error");
}
有人在这看到问题吗?
编辑:这是我修改后的代码
public static async Task copyFile(Microsoft.Graph.GraphServiceClient client, string SourceDriveId, string SourceItemId, string DestinationDriveId, string DestinationFolderId, string FileName)
{
try
{
var destRef = new Microsoft.Graph.ItemReference()
{
DriveId = DestinationDriveId,
Id = DestinationFolderId
};
await client.Drives[SourceDriveId].Items[SourceItemId].Copy(null, destRef).Request().PostAsync();
//await client.Drives[SourceDriveId].Root.ItemWithPath(itemFileName).Copy(parentReference: dest).Request().PostAsync();
}
catch (Microsoft.Graph.ServiceException ex)
{
throw new Exception(ex.Message);
}
}
上述修订后的代码继续给出同样的错误;然而,今晚,它也发生在一个13.8mb的文件上,以前工作正常 .
从逻辑上讲,因为较小的文件不会发生错误,我认为它与文件大小有关 .
响应应该是带有位置 Headers 的202 . 见Copy Item in Graph Docs;但是,我从来没有能够获得位置 Headers . 我怀疑Microsoft Graph没有从OneDrive API获取位置标头信息,因此抛出了网关超时错误 .
1 回答
我相信这就是你要找的东西:
这将采用给定的
DriveItem
并将其复制到另一个Drive
中的文件夹中 .