2

I am trying to implement Upload large files with an upload session.

For now I have (getting the upload session):

UploadSession uploadSession = await graphClient
    .Users["user3@myComp.onmicrosoft.com"]
    .Drive
    .Root
    .ItemWithPath(@"\someFolder\file.txt")
    .CreateUploadSession()
    .Request()
    .PostAsync();

The response from this request is some session URL but when I upload the file chunk to this URL I'm getting an error:

{
  "error": {
    "code": "invalidRequest",
    "message": "DeferCommit was set to false for this upload session."
  }
}

Does anyone know what causes this error?

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
Codey
  • 487
  • 1
  • 8
  • 27
  • Are you using the [production](https://github.com/microsoftgraph/msgraph-sdk-dotnet) or the [beta](https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet) version of the SDK? – Marc LaFleur May 29 '19 at 14:08
  • @MarcLaFleur I have downloaded the latest version of `Microsoft.Graph` from NuGet, after some canges in my code the error repaced with: `{"error":{"code":"invalidRequest","message":"The Content-Range header is missing or malformed."}}` – Codey May 30 '19 at 04:11
  • `Content-Range` is used when you're uploading chunks, not when you are creating a session. Whatever is happening, your code sample doesn't show enough. – Marc LaFleur May 30 '19 at 21:03

1 Answers1

2

Without seeing how the request to upload the bytes was made I'm left to guess a little - but I believe the issue is that you used a POST instead of a PUT. The session URL returned needs to have PUT requests made to it, with appropriate Content-Range headers, in order to upload and commit the data.

Brad
  • 4,089
  • 2
  • 16
  • 26