Skip to content

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

@lavinir

Description

@lavinir

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]}"}}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions