SOLVED
Home

Graph API to invite user works only under "root"

%3CLINGO-SUB%20id%3D%22lingo-sub-655320%22%20slang%3D%22en-US%22%3EGraph%20API%20to%20invite%20user%20works%20only%20under%20%22root%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-655320%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20use%20Graph%20API%20to%20invite%20user%20to%20a%20folder%20that%20is%20hosted%20in%20SharePoint%20Online.%20I%20am%20using%20following%20API%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fgroups%2F%7BgroupId%7D%2Fdrive%2Fitems%2F%7BitemId%7D%2Finvite%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fgroups%2F%7BgroupId%7D%2Fdrive%2Fitems%2F%7BitemId%7D%2Finvite%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20my%20folder%20that%20I%20am%20attempting%20to%20share%20is%20located%20under%20%22Root%22%20of%20document%20library%20no%20problem%20this%20works%20fine%2C%20but%20if%20my%20folder%20is%20located%20under%20%22root%2FGeneral%22%20(because%20I%20want%20to%20be%20visible%20in%20teams%20easily%20API%20Returns%20error%20below.%20Any%20ideas%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3CSPAN%3E%22error%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%7B%3C%2FSPAN%3E%3CSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%26nbsp%3B%3CSPAN%3E%22code%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%3C%2FSPAN%3E%3CSPAN%3E%22invalidRequest%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3CSPAN%3E%22message%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%3C%2FSPAN%3E%3CSPAN%3E%22The%20request%20is%20malformed%20or%20incorrect.%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%3CSPAN%3E%22innerError%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%22request-id%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%3C%2FSPAN%3E%3CSPAN%3E%22%7Bid%7D%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%22date%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20%3C%2FSPAN%3E%3CSPAN%3E%22%7Bdate%7D%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-663705%22%20slang%3D%22en-US%22%3ERe%3A%20Graph%20API%20to%20invite%20user%20works%20only%20under%20%22root%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-663705%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F169240%22%20target%3D%22_blank%22%3E%40Ivan%20Palikuca%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tested%20the%20case%2C%20both%20cases%20are%20working%20fine%20in%20my%20end.%20Actually%20you%20have%20to%20replace%20the%20%7BitemId%7D%20by%20%3CSUB%20folder%3D%22%22%20id%3D%22%22%3E%20and%20you%20should%20not%20include%20the%20sub%20folder%20name%20(General)%20in%20graph%20url.%3C%2FSUB%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fgroups%2F%7BgroupId%7D%2Fdrive%2Fitems%2F%7Bfolder_Id%7D%2Finvite%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fgroups%2F%7BgroupId%7D%2Fdrive%2Fitems%2F%7Bsub_folder_Id%7D%2Finvite%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20should%20not%20provide%20like%20below%20URL%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fgroups%2F%7BgroupId%7D%2Fdrive%2Fitems%2FGeneral%2F%7Bsub_folder_Id%7D%2Finvite%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Ivan Palikuca
New 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
Highlighted
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