Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Get Analytics Activity from CSOM to get "Who viewed this file"

$
0
0

Hi!

Inside this option  you can view the viewers of a given file:

I need to access this information by using CSOM.

I know there is a way to access it by using the REST APIs:

https://tenant-my.sharepoint.com/personal/<EDITED>/_api/v2.0/drive/items('3e1fc715-df4c-409e-8b97-2ebd81d9eba2')/analytics/allTime?$expand=activities($filter=access ne null)

However I am coding a third party solution and the customer may not want to register any application, so in this case I should use CSOM to get the same information.

In the code if I issue the above REST API and I set the credentials using this code:

                    CookieContainer container = new CookieContainer();
                    string szCookie = cred.GetAuthenticationCookie(new Uri(szLoginUrl));
                    container.SetCookies(new Uri(szLoginUrl), szCookie);
                    endpointRequest.CookieContainer = container;
                    endpointRequest.Headers[HttpRequestHeader.Cookie] = szCookie;

Then it does not work (I get an error 403).

Is there a way to natively get the viewer using CSOM, or to call REST APIs from CSOM?

Thanks


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>