KoenZomers / OneDriveAPI

API in .NET Framework 4.8.0, .NET Core 3.1 and .NET 6.0 to communicate with OneDrive Personal and OneDrive for Business
Eclipse Public License 1.0
109 stars 34 forks source link

I don't know why. Please take a look at it for me. #27

Closed bbhxwl closed 3 years ago

bbhxwl commented 3 years ago

I don't know why. Please take a look at it for me. I can get root, which is the same as your demo, but I upload it, why fail, and your demo is OK? {"error":{"code":"invalidRequest","message":"Item does not match expected type"}}

static void Main(string[] args) {

       var t= Task.Run(async()=> {

            oneDrive = new OneDriveConsumerApi("*****", "*******");
            oneDrive.AuthenticationRedirectUrl = "******";
            string url = "http://*****.com/?code=M.R3_BAY.d88******";
            string msg = oneDrive.GetAuthorizationTokenFromUrl(url);
             await oneDrive.GetAccessToken();

           while (true)
            {
               try
               {
                   string path = Console.ReadLine();
                   var root = await oneDrive.GetDriveRoot();
                      var f=    await oneDrive.UpdateFileViaSimpleUpload(new FileInfo(path),root);
                  // var f = await oneDrive.UpdateFile(path,new KoenZomers.OneDrive.Api.Entities.OneDriveItem() {  });
                   Console.WriteLine(f.OriginalJson);
               }
               catch (Exception ex)
               {
                   Console.WriteLine(ex.Message);

               }

            }

        });
        t.Wait();

    }
bbhxwl commented 3 years ago

I wrote upload as updatefile.. I got it! thank you. I manually get the URL of getauthorizationtokenfromurl myself. If my program is closed, the URL will be expired and can only be obtained once. Is there any way to recycle it?

KoenZomers commented 3 years ago

See https://github.com/KoenZomers/OneDriveAPI/issues/26