Invite group to SPO document library using MS Api Graph

Sie7ex 0 Reputation points


I want to grant permissions to a group on a document library I have created in SharePoint using the MS Graph API.

I can read permissions using:


I can remove permissions using:


But when I try to add a group using:

var requestBody = new InvitePostRequestBody {
    Recipients = lstRecipients,
    RequireSignIn = true,
    SendInvitation = false,
    Roles = new List<string>() { "write"},
    RetainInheritedPermissions = true

I get the error "invalidRequest"

On the other hand, I can add permissions to an item within a document library using this method (It's just that in this case, I have an item ID different from the drive ID), but I cannot do so for the document library itself.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,315 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,789 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AsithwMSFT 1,420 Reputation points Microsoft Vendor

    Hi @Sie7ex

    The documentation indicates that the message property is not optional. could you give a try including this property to the request body

      "requireSignIn": false,
      "sendInvitation": false,
      "roles": [ "read | write"],
      "recipients": [
        { "@odata.type": "microsoft.graph.driveRecipient" },
        { "@odata.type": "microsoft.graph.driveRecipient" }
      "message": "string"