My application can upload files into OneDrive, SharePoint normally by Consecutive Upload. For now, It is broken, and throw InternalServerError when calling
var uploadSession = await graphClient.Drive.Items["01KGPRHTV6Y2GOVW7725BZO354PWSELRRZ"].ItemWithPath("_hamilton.png").CreateUploadSession().Request().PostAsync();
I implement follow: [https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/tests/Microsoft.Graph.DotnetCore.Test/Requests/Functional/OneDriveTests.cs][1]
Exception:
Status Code: InternalServerError
Microsoft.Graph.ServiceException: Code: InternalServerError
Message: Object reference not set to an instance of an object.
Inner error:
AdditionalData:
request-id: b3ab4fbb-e3c2-4e07-a353-4e2a73b5bf67
date: 3/10/2020 4:25:56 AM
ClientRequestId: b3ab4fbb-e3c2-4e07-a353-4e2a73b5bf67
at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
SDK: Microsoft.Graph 1.21.0
We also got the same issue, but it seems that it's an issue with the Graph API that (probably) changed today (2020-03-10). Someone has filed a github issue at https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/646 which you can follow, but if you really have to make this work, you can hack around it by overriding the request url using reflection.
var regex = new Regex(@"/microsoft\.graph\.createUploadSession$");
var reqUrl = uploadSessionReq.RequestUrl;
typeof(DriveItemCreateUploadSessionRequest)
.GetProperty(nameof(DriveItemCreateUploadSessionRequest.RequestUrl))
.GetSetMethod(nonPublic: true)
.Invoke(
uploadSessionReq,
new[]
{
regex.Replace(reqUrl, "/createUploadSession")
}
);