/invite endpoint "notAllowed" but /createLink ok in Sharepoint via Graph API

Lemo_admin 0 Reputation points
2024-04-30T11:43:26.8633333+00:00

Hi,

I don't understand why I can create a sharing link via the POST /sites/{siteId}/drive/items/{itemId}/createLink endpoint but when I try to use the POST /sites/{siteId}/drive/items/{itemId}/invite endpoint I receive a 403 with this body:

{
  "error": {
    "code": "notAllowed",
    "message": "Operation not allowed"
  }
}

The api permissions needed to use one or another seems to be the same, so why I could be getting this error?

It also happens if I set the parameter "requireSignIn" to true and if I remove "sendInvitation" parameter.

There is something I can configure as admin in sharepoint or somewhere else to allow the /invite ?

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,768 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 37,466 Reputation points
    2024-05-01T09:46:43.5833333+00:00

    Hi @Lemo_admin

    I tested the API locally and it worked fine for me. Also, when I call the endpoint using a GET request, it throws the same error as yours, so make sure you are using a POST request and not a GET request.

    User's image

    Hope this helps.

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


  2. Hitesh Pachipulusu - MSFT 80 Reputation points Microsoft Vendor
    2024-05-03T11:29:21.92+00:00

    Hello @Lemo_admin ,

    I am able to reproduce the issue from my end and noticed that request body is missed. Please refer below image where request body is empty.

    User's image

    Please refer to the documentation https://learn.microsoft.com/en-us/graph/api/driveitem-invite?view=graph-rest-1.0&tabs=http.

    After providing a valid request body we are able to get 200 status code.

    User's image

    User's image

    Hope this helps.

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