SOLVED

Graph API to invite user works only under "root"

Copper Contributor

I am trying to use Graph API to invite user to a folder that is hosted in SharePoint Online. I am using following API:

 

https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/{itemId}/invite

 

When my folder that I am attempting to share is located under "Root" of document library no problem this works fine, but if my folder is located under "root/General" (because I want to be visible in teams easily API Returns error below. Any ideas?

 

{
 "error": { 
 "code": "invalidRequest",
 "message": "The request is malformed or incorrect.",
  "innerError": {
   "request-id": "{id}",
   "date": "{date}"
  }
 }
}
1 Reply
best response confirmed by Ivan Palikuca (Copper Contributor)
Solution

@Ivan Palikuca 

 

I have tested the case, both cases are working fine in my end. Actually you have to replace the {itemId} by <sub folder id> and you should not include the sub folder name (General) in graph url.

 

For example :

 

https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/{folder_Id}/invite

 

https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/{sub_folder_Id}/invite

 

You should not provide like below URL :

 

https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/General/{sub_folder_Id}/invite

 

1 best response

Accepted Solutions
best response confirmed by Ivan Palikuca (Copper Contributor)
Solution

@Ivan Palikuca 

 

I have tested the case, both cases are working fine in my end. Actually you have to replace the {itemId} by <sub folder id> and you should not include the sub folder name (General) in graph url.

 

For example :

 

https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/{folder_Id}/invite

 

https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/{sub_folder_Id}/invite

 

You should not provide like below URL :

 

https://graph.microsoft.com/v1.0/groups/{groupId}/drive/items/General/{sub_folder_Id}/invite

 

View solution in original post