Microsoft Graph Error - Resource not found for the segment 'root:' when uploading file to OneDrive

后端 未结 1 370
刺人心
刺人心 2021-01-28 16:31

When working on this tutorial on Uploading File to OneDrive from Microsoft Graph OneDrive team, I\'m getting the following error at the last line of the code shown

1条回答
  •  鱼传尺愫
    2021-01-28 16:59

    .ItemWithPath(file.Path) isn't the path to the file you're uploading, it is the destination path.

    For example, if you wanted to upload "SomeFile.txt" to the root of your OneDrive, you would use:

    graphClient.Me.Drive // The drive
      .Root // The drive's root folder
      .ItemWithPath("SomeFile.txt") // The destination to write the upload to
    

    The reason this is currently failing is OneDrive doesn't know what to do with a Windows drive path (i.e. C:\Files\Documents\SomeFile.txt). It expects a URL safe drive path (i.e. /Documents/SomeFile.txt).

    0 讨论(0)
提交回复
热议问题