Anthony Phan
Anthony Phan

Reputation: 423

Microsoft Graph API set owner role for file

Using Microsoft Graph is it possible to assign a the "owner" role to a SharePoint drive item? I can achieve this using the UI but do not seem to be able to do this using Graph.

I have tried the following method:

PATCH https://graph.microsoft.com/v1.0/groups/{groudId}/sites/root/drives/{driveId}/items/{itemId}/permissions/{permId}

Body:
{
    "roles": [
        "owner"
    ]
}


Return:
{
    "error": {
        "code": "invalidRequest",
        "message": "Invalid value for role",
        "innerError": {
            "date": "2023-01-07T07:57:17",
            "request-id": "b849af34-5b2d-4f50-94bd-b6ac15947eb8",
            "client-request-id": "224905e8-ffb3-2dd1-6223-60ec9e5ad2a9"
        }
    }
}

However what confuses me is if I assign the same permission group full control to the drive item in the UI the same permission object will return "owner" as the role.

Upvotes: 1

Views: 353

Answers (1)

user2250152
user2250152

Reputation: 20625

I was facing the similar issue long time ago and fixed it by using sp.full control instead of owner. Maybe it will work for you.

PATCH /v1.0/groups/{groudId}/sites/root/drives/{driveId}/items/{itemId}/permissions/{permId}

Body:
{
    "roles": [
        "sp.full control"
    ]
}

Upvotes: 1

Related Questions