Invate an Azure USER to my sharepoint

Nadjim 61 Reputation points
2022-10-16T12:00:41.673+00:00

Hi :),

I use the Invite function to invite an external user to my sharepoint:

POST /me/drive/items/{item-id}/invite  
 Content-type: application/json  
      
 {  
   "recipients": [  
     {  
       "email": "user@externaldomain.com"  
     }  
   ],  
   "message": "Here's the file that we're collaborating on.",  
   "requireSignIn": true,  
   "sendInvitation": false,  
   "roles": [ "read" ]  
 }  

I am having problems. Indeed, I do not have the same answer all the time :

Example 1 :

<?xml version="1.0" encoding="UTF-8"?>  
<root odata.context="https://graph.microsoft.com/v1.0/$metadata#Collection(permission)">  
 <value odata.type="#microsoft.graph.permission">  
 <id>aTowIy5mfG1lbWJlcnNoaXB8dGlDH872kjhfXJlLmVlI2V4dCNAc29sbzEuyeud73UYyb3NvZnQuY29t</id>  
 <roles>read</roles>  
 <grantedTo>  
 <user>  
 <email>test@XXXXX.ee</email>  
 <id>4a79tyj8-a156-ty76-afe6-018a2529eg8f</id>  
 <displayName>Test JDA</displayName>  
 </user>  
 </grantedTo>  
 </value>  
</root>  

And some time i have this, example 2 :

<?xml version="1.0" encoding="UTF-8"?>  
<root odata.context="https://graph.microsoft.com/v1.0/$metadata#Collection(permission)">  
 <value odata.type="#microsoft.graph.permission">  
 <roles>read</roles>  
 <grantedToIdentities>  
 <user>  
 <email>XXXXX@gmail.com</email>  
 </user>  
 </grantedToIdentities>  
 <invitation>  
 <signInRequired>true</signInRequired>  
 </invitation>  
 <link>  
 <type>view</type>  
 <webUrl>https://TEST.sharepoint.com/:f:/s/TEST/LSDHKJSGKJFGL8798687_7896DSFHJ</webUrl>  
 </link>  
 </value>  
</root>  

The second one it's perfect for me beaucause I have the WebURL.

I think in the first example it's the answer you get when you invite an Azure user. How can I fix this problem to always have the answer of the second example with the WebURL?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,445 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,900 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bhanu Kiran 3,526 Reputation points
    2022-10-17T07:29:53.99+00:00

    Hi @Nadjim ,

    As per my testing, response of your 1st example is returned when we try to grant access using Add permission graph API endpoint:

    POST /me/drive/items/{item-id}/invite - response example

    2nd example response is returned when we try to grant access using grant access to sharing link graph API endpoint:

    POST /shares/{encoded-sharing-url}/permission/grant - response example

    The Link property(weblink) in response is queried only when we provide the access using sharing link. Please refer the documentation

    Please refer this link for more details.

    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"