locked
One Drive API RRS feed

  • Question

  • Hi I want develop a console application which uploads a file to my one drive. My queries are as follows :

    1) Is OneDrive api compatibale with .NET Framework 3.5

    2) Below is the code I was trying,I couldnt find the implementation of the method "GetAccessToken". How can we programmatically authenticate a user in a windows console app

    private static void UploadFileToSkyDrive(string localFile)
            {
                string url =
                  string.Format(@"https://apis.live.net/v5.0/folder.4515677bdf99b35f/  files/{0}?access_token={1}", Path.GetFileName(localFile), GetAccessToken());

                using (var client = new WebClient())
                {
                    var result = client.UploadData(new Uri(url), "PUT");
                    string strResult = Encoding.UTF8.GetString(result);
                }
            }

    Thanks in advance

    Rahul.

    Monday, September 17, 2018 11:33 AM