Invalid request when trying to invite using graph api

Nithin Anand 0 Reputation points
2023-09-21T04:27:33.6433333+00:00

Hi

Need help with an api request for the POST call to share a drive item

url = "https://graph.microsoft.com/v1.0/users/xxxxxx52-xxe0-xxf7-xxfa-xxxxxxc129fa/drive/items/xxxxxxxxxxxOBTDY3NJBE2MSPJTNBJCYQI/invite"

payload = 
{  "recipients": [    {      "email": "******@cudacodeus.onmicrosoft.com"    }  ],  "message": "Here's the file that we're collaborating on.",  "requireSignIn": True,  "sendInvitation": True,  "roles": [ "write" ]}

response = 
{'error': {'code': 'invalidRequest', 'message': 'Invalid request', 'innerError': {'date': '2023-09-21T04:16:38', 'request-id': '9e8b7396-684f-4e92-b7fc-6c37ffb5f0bb', 'client-request-id': '9e8b7396-684f-4e92-b7fc-6c37ffb5f0bb'}}}
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Diah.Karim-MSFT 335 Reputation points Microsoft External Staff
    2024-01-08T04:25:16.09+00:00

    Hi Nithin,

    I think your can refer this document create the share link

    https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http

    Here is the screenshot for creating the share link. Use the webUrl to open the file. You also can set a password when creating the link

    Share

    Hope this helps.

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

    0 comments No comments

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.