Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.Graph.Models.ODataErrors.ODataError: Invalid request when calling createUploadSession (OneDrive) #2750

Open
lavinir opened this issue Nov 20, 2024 · 2 comments
Labels

Comments

@lavinir
Copy link

lavinir commented Nov 20, 2024

Describe the bug

I'm trying to create an upload session using the Graph SDK. With many different OneDrive accounts this results in an ODataError : Invalid Request.

Additional Details:

  • Does not seem to effect all accounts.
  • Item resides inside the Special AppFolder

Expected behavior

Upload Session should be created successfully or at least a meaningful error returned to understand what's wrong with the request.

How to reproduce

Using the following code:

            var uploadSession = await graphClient.Drives[driveId]
                .Items[appFolder.Id]
                .ItemWithPath(destinationFileName)
                .CreateUploadSession
                .PostAsync(new DriveUpload.CreateUploadSessionPostRequestBody()
                {
                    Item = new DriveItemUploadableProperties
                    {
                        Description = description
                    }
                });

SDK Version

Graph: 5.62.0, Graph.Core: 3.2.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ``` Error: Error uploading backup: Microsoft.Graph.Models.ODataErrors.ODataError: Invalid request at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponseAsync(HttpResponseMessage response, Dictionary2 errorMapping, Activity activityForAttributes, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken) at Microsoft.Graph.Drives.Item.Items.Item.CreateUploadSession.CreateUploadSessionRequestBuilder.PostAsync(CreateUploadSessionPostRequestBody body, Action1 requestConfiguration, CancellationToken cancellationToken) at hassio_onedrive_backup.Graph.GraphHelper.UploadFileAsync(String filePath, DateTime date, String instanceName, TransferSpeedHelper transferSpeedHelper, String destinationFileName, Action2 progressCallback, Boolean flatten, String description) ```

Configuration

OS: Linux
Architecture: ARM64, x64

Other information

Sample Request:
URL:
https://graph.microsoft.com/v1.0/drives/4A4F1C96B648045A/items/4A4F1C96B648045A%211858:/hass_backup_2024-11-20-12-45.tar:/createUploadSession

Body:
{"item":{"description":"{\u0022Slug\u0022:\u0022bfebf0aa\u0022,\u0022BackupDate\u0022:\u00222024-11-20T12:45:43.188392\u002B01:00\u0022,\u0022InstanceName\u0022:null,\u0022IsProtected\u0022:false,\u0022Size\u0022:570.58,\u0022BackupType\u0022:\u0022full\u0022,\u0022Addons\u0022:[],\u0022Folders\u0022:[\u0022share\u0022,\u0022addons/local\u0022,\u0022ssl\u0022,\u0022media\u0022]}"}}

@andrueastman
Copy link
Member

Thanks for raising this @lavinir

It looks like the description field being set in the DriveItemUploadableProperties is a json object that is stringified. I suspect its possible that it may contain a character that the API does not like.

To rule this out, are you able to make a successfull request if you create an upload session with a hardcoded description that is a plain string to validate?

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Dec 3, 2024
@lavinir
Copy link
Author

lavinir commented Dec 3, 2024

Thanks @andrueastman.
I think you're correct about the description field causing the issue but I'm not sure what characters are causing this. I tried sending the body above from my machine but this did not reproduce the issue even though it was failing for other users.

I ended up removing the description altogether and that resolved the issue.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants