Microsoft Graph API - Upload large file - Azure AD App with Sites.selected permission

Viewed 301

I have registered an application on our Azure AD, and granted it the Sites.Selected permission as well as granting it access to a specific Sharepoint site following this guide. (Sites.ReadWrite.All is not an option as it would give access to all sites)

https://ashiqf.com/2021/03/15/how-to-use-microsoft-graph-sharepoint-sites-selected-application-permission-in-a-azure-ad-application-for-more-granular-control/

Now I am trying to use Postman to send web requests to the Microsoft Graph API in order to upload large files so I want to use the createUploadSession endpoint. https://graph.microsoft.com/v1.0/sites/{{site_id}}/drive/items/{{Item_id}}:/test.rtf:/createUploadSession

But I get the error:

{
    "error": {
        "code": "notAllowed",
        "message": "Operation not allowed",
        "innerError": {
            "date": "2022-02-04T14:04:37",
            "request-id": "06e86b5b-6067-4d7b-9ce9-af41de95406f",
            "client-request-id": "06e86b5b-6067-4d7b-9ce9-af41de95406f"
        }
    }
}

I know the authentication token I use is valid because a request to directly upload a file works fine and uploads the file. https://graph.microsoft.com/v1.0/sites/{{site_id}}/drive/items/{{Item_id}}:/test.rtf:/content

Any ideas for what could be wrong with my request to start an upload session?

1 Answers

I suppose that item_id is id of the destination folder but I'm not sure whether you can upload large this way

v1.0/sites/{{site_id}}/drive/items/{{Item_id}}:/test.rtf:/createUploadSession

Try to specify the path to the file from the root

POST v1.0/sites/{{site_id}}/drive/items/root:/test.rtf:/createUploadSession

Also check whether the POST HTTP method is set.

Related