Hi all,
For my UWP app I want add Onedrive function so the user can upload and download a file from his/her Onedrive. So I followed this guide from Microsoft / MSFT (https://msdn.microsoft.com/en-us/magazine/mt632271.aspx?f=255&MSPPError=-2147217396 ).
The uploading part works (I see newly created files in my onedrive account that I can open manually) but the downloading/reading part gives the following error:
"Microsoft.Graph.ServiceException: Code: itemNotFound
Message: Item does not exist"
But the item / file does exist and the path used is the same as when I upload the file. I also checked if I added right scopes, and checked if it worked with User.Read / files.read.all. I also tried the newer version of the Onedrive SDK which is within the Microsoft Graph API, but I got the same error.
Here is my code in c# to read the file (note that the exception is thrown so the try{} part fails):
Does anyone perhaps know how to solve this issue or where I can get a book about the Onedrive sdk? I want to learn more about this but MSFT's documentation does not help me much. :unhappy:
For my UWP app I want add Onedrive function so the user can upload and download a file from his/her Onedrive. So I followed this guide from Microsoft / MSFT (https://msdn.microsoft.com/en-us/magazine/mt632271.aspx?f=255&MSPPError=-2147217396 ).
The uploading part works (I see newly created files in my onedrive account that I can open manually) but the downloading/reading part gives the following error:
"Microsoft.Graph.ServiceException: Code: itemNotFound
Message: Item does not exist"
But the item / file does exist and the path used is the same as when I upload the file. I also checked if I added right scopes, and checked if it worked with User.Read / files.read.all. I also tried the newer version of the Onedrive SDK which is within the Microsoft Graph API, but I got the same error.
Here is my code in c# to read the file (note that the exception is thrown so the try{} part fails):
var _scopes = new[]
{
"onedrive.readwrite",
"onedrive.appfolder",
"wl.signin"
};
var _client = OneDriveClientExtensions.GetUniversalClient(_scopes);
var _session = await _client.AuthenticateAsync();
Debug.WriteLine($"Token: {_session.AccessToken}");
var builder = _client.Drive.Root.ItemWithPath("Public/Test"); ///MyFile.txt
try
{
var file = await builder
.Request()
.GetAsync();
var contentStream = await builder.Content
.Request()
.GetAsync();
Debug.WriteLine($"Content for file {file.Name}:");
using (var reader = new StreamReader(contentStream))
{
Debug.WriteLine(reader.ReadToEnd());
}
}
catch (Exception ex)
{
Debug.WriteLine("Onedrive builder request exception: " + ex.ToString());
}
Does anyone perhaps know how to solve this issue or where I can get a book about the Onedrive sdk? I want to learn more about this but MSFT's documentation does not help me much. :unhappy: