Search code examples
c#office365o365rwsclient

Unable to access SPOOneDriveForBusinessFileActivity REST API call


I'm using Microsoft's o365 REST API Client library (https://github.com/Microsoft/o365rwsclient) and have been able to get many of the API calls to work, but am not having any luck with "SPOOneDriveForBusinessFileActivity". Also, I don't see it advertised in the o365 web service atom feed at https://reports.office365.com/ecp/reportingwebservice/reporting.svc

Here is a description of what the events should return : https://support.office.com/en-gb/article/Understanding-the-User-activity-logs-report-80d0b3b1-1ee3-4777-8c68-6c0dedf1f980

Looking at the source code in https://github.com/Microsoft/o365rwsclient/blob/master/TenantReport/SPOOneDriveForBusinessFileActivity.cs it appears to be a valid function, but when utilizing the o365rwsclient library from a c# application (below) I get a 404 error (URL not found).

Any ideas what's going on? Is this report implemented (Powershell cmdlet or direct REST call would also be acceptable)- and if so, how can I access it?

using Microsoft.Office365.ReportingWebServiceClient;
using System;

namespace O365ReportingDataExport
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            ReportingContext context = new ReportingContext();
            //If you enter invalid authentication information, Visual Studio will throw an exception.
            context.UserName = @"PUT YOUR OFFICE 365 USER EMAIL ADDRESS HERE";
            context.Password = @"PUT YOUR OFFICE 365 USER PASSWORD HERE";
            //FromDateTime & ToDateTime are optional, default value is DateTime.MinValue if not specified
            context.FromDateTime = DateTime.MinValue;
            context.ToDateTime = DateTime.MinValue;
            context.SetLogger(new CustomConsoleLogger());

            IReportVisitor visitor = new CustomConsoleReportVisitor();

            ReportingStream stream1 = new ReportingStream(context, "SPOOneDriveForBusinessFileActivity", "stream1");
            //Calls VisitReport 
            stream1.RetrieveData(visitor);

            Console.WriteLine("Press Any Key...");
            Console.ReadKey();
        }

        private class CustomConsoleLogger : ITraceLogger
        {
            public void LogError(string message)
            {
                Console.WriteLine(message);
            }

            public void LogInformation(string message)
            {
                Console.WriteLine(message);
            }
        }

        private class CustomConsoleReportVisitor : IReportVisitor
        {
            public override void VisitBatchReport()
            {
                foreach (ReportObject report in this.reportObjectList)
                {
                    VisitReport(report);
                }
            }

            public override void VisitReport(ReportObject record)
            {
                Console.WriteLine("Record: " + record.Date.ToString());
            }
        }
    }
}

Solution

  • After talking to Microsoft's O365 support team, it appears that being able to see file activity in OneDrive for Business is a feature that is still in internal testing (hence being able to see it in their REST API's) that has not been deployed yet.