New to Telerik Report Server? Download free 30-day trial

Downloading All Reports Stored on Report Server

Environment

Product Progress® Telerik® Report Server

Description

This article explains how to download all report definitions that are stored on the Report Server with the Report Server API.

Solution

In our GitHub repository, you can find a Console application that downloads all TRDP/TRDX reports that are stored on the Report Server. Below are the required steps for building the application:

  • Add the following references:
    • Telerik.Reporting;
    • Telerik.ReportServer.HttpClient;
    • Telerik.ReportServer.Services.Models.
  • Create a setting for the Report Server connection;
var settings = new Telerik.ReportServer.HttpClient.Settings()
            {
                BaseAddress = "http://localhost:83/"
            };
  • Get all categories in the Report Server and for each of them get the reports:
using (var rsClient = new ReportServerClient(settings))
            {
                rsClient.Login("username", "password");
                var categories = rsClient.GetCategories();
                foreach (var category in categories)
                {
                    var reportInfos = rsClient.GetReportInfosInCategory(category.Id);
                    foreach (var reportInfo in reportInfos)
                    {
                        var reportId = reportInfo.Id;
                        var reportDefinition = rsClient.GetLatestReportRevision(reportId);
                        SaveReportDefintion(reportDefinition, reportInfo.Name);
                    }
                }
            }
  • Finally, save the report definitions:
private static void SaveReportDefintion(Telerik.ReportServer.Services.Models.ReportRevisionContent reportDefinition, string name)
        {
            var extension =reportDefinition;
            string path = "filepath" + name;
            File.WriteAllBytes(path + reportDefinition.Extension, reportDefinition.Content);
        }
In this article