Reporting API

Current version: 9.2

The following example demonstrates how to submit a T-SQL query to the Reporting Service via the Reporting API:

RequestResponse
using Sitecore.Configuration;
using Sitecore.Xdb.Reporting;

namespace Documentation.Examples
{
    class ReportingAPI
    {
        public void Example()
        {
            var provider = (ReportDataProvider)Factory.CreateObject("reporting/dataProvider", true);

            var query = new ReportDataQuery("select COUNT(visits) from fact_downloads groupby asset_id");

            string datasource = "reporting";

            ReportDataResponse response = provider.GetData(datasource, query, new CachingPolicy { NoCache = true });

            var datatable = response.GetDataTable();
        }
    }
}
Note

The Reporting API has the limitation that the service can only return a data table, and you cannot use SQL input/output parameters.

Do you have some feedback for us?

If you have suggestions for improving this article,