How to upload file to Onedrive using ASP.NET MVC?

18 Views Asked by At

I had a problem, then I authenticated my account using Microsoft. I want to upload files. But I can not do that.

Here is my source code (my English sorry is not good, please help me if you have a solution); I have tried all options, but had no success.

Thank you.

var folderName = "YourFolderName"; 
var fileName = file.FileName;
var url = $"https://api.onedrive.com/v1.0/drive/me/root:/{folderName}/{fileName}:/upload.createSession";
var request = WebRequest.Create(url);
request.Method = "POST";
request.Headers.Add("Authorization", "Bearer " + accessToken);
request.ContentType = "application/octet-stream";
0

There are 0 best solutions below