Get OneDrive Item Id for Current Word doc in a group drive
Asked Answered
K

0

6

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 like https://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

  1. Is it guaranteed that groupnamelikestring === mailNickName?

  2. what happens when group name gets renamed?

  3. what happens if mailNickName updated using PATCH 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 step
  • pathtodoc : This is path to document we git from document url.
Kinakinabalu answered 18/9, 2017 at 8:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.