3

I am getting the below error when creating upload session (Microsoft Graph Api).

{ "error": { "code": "invalidRequest", "message": "Invalid request", "innerError": { "request-id": "6e9cc58e-d3b9-456e-a794-90486969296e", "date": "2020-04-06T20:53:18" } } }

Post request https://graph.microsoft.com/v1.0/me/drive/root:/testapi:/createUploadSession

Request body :

1
  • I am using Microsoft SDK for java, I am not able to figure out, how to send conflictBehavior with upload session. How did you pass? Commented Jul 9, 2020 at 14:43

3 Answers 3

3

I have modified the request as below to make it work. See below :

POST https://graph.microsoft.com/v1.0/me/drive/items/01WCLVX5B7JBMYFMQKWNA3NVFODWCDUPGB:/3.pdf:/createUploadSession

Sign up to request clarification or add additional context in comments.

3 Comments

Also set the below properties : Authorization = Bearer + token Content-Type = application/json Method = POST JSON Body below : conflictBehavior = Rename name = 3.pdf(filename)
I am using Microsoft SDK for java, I am not able to figure out, how to send conflictBehavior with upload session. How did you pass?
Below is my code snippet ; Try setting up in JSON Data. : SET OutputLocalEnvironment.Destination.HTTP.RequestURL = 'https://'||ecMicroGraphurl||'/v1.0/drives/'||cDriveId||'/items/'||cItemId||':/'||Environment.Variables.InputFileName||':/createUploadSession'; SET OutputRoot.JSON.Data TYPE = JSON.Array; CREATE FIELD OutputRoot.JSON.Data.Item IDENTITY (JSON.Object)Item; SET OutputRoot.JSON.Data.Item."@microsoft.graph.conflictBehavior" = 'replace'; SET OutputRoot.JSON.Data.Item.name = Environment.Variables.InputFileName;
0

I was implementing C# from here where the code was

var uploadSession = await graphClient.Me.Drive.Root
    .ItemWithPath(itemPath)
    .CreateUploadSession(uploadProps)
    .Request()
    .PostAsync();

In my case, I was able to fix it by updating itemPath by adding the full path to the file. For instance, if the path is

/RootFolder/Folder1

just update with file name like this

/RootFolder/Folder1/MyFile.pdf

Comments

0

Microsoft Graph API is a PITA. That said, this worked for me:

/drives/${driveId}/${childId}:/${filename}:/createUploadSession

If you are uploading to Sharepoint (instead of OneDrive), be sure to include only valid properties in the body payload (more here). This worked for me:

        {
            "item": {
                "name": "filename.txt"
            }
        }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.