question

NaveedKhan-2113 avatar image
0 Votes"
NaveedKhan-2113 asked saldana-msft edited

API's to fetch Files/documents related metadata on SharePoint

Hi Team,

There is an urgent requirement in my project to fetch below metadata of a file on Sharepoint using API.

1.Number of comments made by the author

2.Time spent by author on the document

3.Number of people who opened the document

4.Total number of open comments etc.

49515-capture.png


49516-capture1.png


Please help me to achieve the above requirements using API. Any help on this will be appreciated.

Thanks,

Pratik


office-sharepoint-onlineoffice-sharepoint-server-developmentmicrosoft-graph-sdkmicrosoft-graph-sites-lists
capture.png (134.3 KiB)
capture1.png (141.4 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Added right tags/teams to assist

0 Votes 0 ·

Do you use SharePoint API's or Microsoft Graph API to fetch the metadata?

0 Votes 0 ·

Hi @Deva-MSFT ,

Earlier I was using SharePoint API's but a few days back I created 1 new Sharepoint site, but that was not accessible with SharePoint API's so right now I am using Microsoft Graph.

But do you have any idea why we are not able to use SharePoint API's now?

49799-n16js.png


0 Votes 0 ·
n16js.png (30.1 KiB)

@BakerKong-MSFT -Need your response to the above query.


Thanks

0 Votes 0 ·
Show more comments
NaveedKhan-2113 avatar image
0 Votes"
NaveedKhan-2113 answered BakerKong-MSFT commented

I want to get Who viewed my files? Show Number of Views and Viewer Names on SharePoint Online files

Can we achieve this with the help of API's as well?

Please refer to the blog for more details.

https://veronicageek.com/microsoft-365/sharepoint-online/who-viewed-my-files-show-number-of-views-and-viewer-names-on-sharepoint-online-files/2020/04/#comment-178

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @NaveedKhan-2113,

I viewed the blog you provided and activated the related feature:

50593-image.png

And below endpoint could get the viewer info:

 https://graph.microsoft.com/v1.0/drives/b!xxxxf-G/items/01CGSxxxxJX7/analytics/allTime?$expand=activities($filter=access ne null)

50623-image.png

Thanks
Baker Kong

1 Vote 1 ·
image.png (29.7 KiB)
image.png (56.4 KiB)

Hi @NaveedKhan-2113,

Regarding this issue, do you have any other questions? And if the above info is helpful to this issue, Can you accept it as an answer?

Thanks
Baker Kong

2 Votes 2 ·

Hey @BakerKong-MSFT ,

I have 1 more query regarding the same.

Currently, we are using the below API to fetch the metadata of a file/document in SharePoint .So can we have any other API to fetch the above information as the below API is not providing the required details?

https://sitename.sharepoint.com/sites/NaveedDemoSN/_api/web/getFileByServerRelativeUrl('/sites/NaveedDemoSN/Shared%20Documents/Test13.docx')/listItemAllFields


Thanks

1 Vote 1 ·
Show more comments
BakerKong-MSFT avatar image
1 Vote"
BakerKong-MSFT answered

Hi @NaveedKhan-2113,

There is analytics resource in MS Graph that could return viewer info:

49776-image.png

And you can get all activities including Comment Action via below endpoint:

https://graph.microsoft.com/beta/drives/b!Nxxx1f-G/items/01xxxJX7/activities?$expand=driveItem

49858-image.png

Best Regards,
Baker Kong


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


image.png (54.3 KiB)
image.png (61.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

NaveedKhan-2113 avatar image
0 Votes"
NaveedKhan-2113 answered BakerKong-MSFT commented

53493-comment.pngHi Team,

I have a requirement to fetch the below details.

Please let me know the API with the help of that we can get the below details.(Refer the attached screenshot)

@BakerKong-MSFT : Please help with this.

1.Number of comments made by the author

2.Total number of open comments etc.



comment.png (255.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi NaveedKhan-2113,

There is no direct way to get Word comments. you may have to use above endpoint to get all activities including Comment Action. After that, you can analyze the result and pick up the comment then count the number.

Thanks
Baker Kong

0 Votes 0 ·