Cannot create an upload session on a folder

anna 20 Reputation points
2023-06-02T12:43:28.34+00:00

I am trying to create an upload session to upload a file to a certain folder:

POST 
https://graph.microsoft.com/v1.0/{{tenant}}/drives/{{drive_id}}/items/XXXXXNHXZFZ3MVQNYJE3LWRLV7FJKHA4/createUploadSession


{
  "@microsoft.graph.conflictBehavior": "fail",
  "description": "test",
  "fileSize": 1234,
  "name": "filename1.txt"
}

The item given in the path is a folder and I get its info with GET request.

Issuing a upload session fails with the error code:

{
    "error": {
        "code": "nameAlreadyExists",
        "message": "Cannot create an upload session on a folder",
        "innerError": {
            "date": "2023-06-02T12:39:13",
            "request-id": "13633383-ad65-4fef-ab89-39dc7f940ab2",
            "client-request-id": "13633383-ad65-4fef-ab89-39dc7f940ab2"
        }
    }
}

How to fix that?

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-06-05T05:26:06.7533333+00:00

    Hi @anna,

    The error response indicates that you are trying to create an upload session on a folder instead of a file. Uploading files using an upload session is usually done for individual files, not for folders.

    User's image

    Here it is recommended to use the path:

    https://graph.microsoft.com/v1.0/drives/root:/Documents/55/filename1.txt:/createUploadSession

    Here is a test for your reference:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.