I'm working on a Office.js
Word
addin but document is stored on group drive.
How can i get either or all of group id
, drive id
and item id
for current document
Related question is here
But solution didn't work for me as it is for personal drive
Current Solution
I have a solution but i'm not sure it is sound
The url I get in getFilePropertiesAsync is in following format
<siteUrl>/sites/<groupnamelikestring>/Shared Documents/<pathtodoc>
siteUrl
: Its a site url likehttps://abc.sharepoint.com
groupnamelikestring
: Not quite group name but something similar where some special characters are removed and everything in lowercase.pathtodoc
: This is path to document in drive and share point.
1. Get Group object
By using following URL
i can get group object
https://graph.microsoft.com/v1.0/groups?$filter=mailNickName eq '<groupnamelikestring>'
This returns required group but I'm not quite sure about mailNickName
property
Is it guaranteed that
groupnamelikestring
===mailNickName
?what happens when group name gets renamed?
- what happens if
mailNickName
updated usingPATCH
call
Is groupnamelikestring
=== mailNickName
is sound?
2. Getting Drive Id
and Item ID
It is straight forard once we have group object. Using following URL
we can get both Drive Id
and Item ID
.
https://graph.microsoft.com/v1.0/groups/<groupid>/drive/root:/<pathtodoc>
Here
groupid
: THis is group ID we got in previous steppathtodoc
: This is path to document we git from document url.