Search results
Suggest a FeaturePDF

How to get the list of items from Bold Reports Report Server

You can get the list of items(Category, Reports, Dataset, Data source, and Schedule) from Bold Reports by using the Get Items API.

To do this, pass the following parameters in query parameters:

itemType - Pass the item type(Category, Reports, Dataset, Data source, or Schedule).

serverPath - The path of the category.

The access token must be passed in the authorization header. To obtain the access token, use the Authentication API or Embed Secret Key API.

Here is a sample C# code to illustrate the approach.

Add the following assemblies to the namespace

  • System.IO
  • Newtonsoft.Json
  • System.Net
  • System.Collections.Generic
  • System.Text

Refer to the Newtonsoft.Json assembly from the nuget package

public class ApiItems
{
   public bool CanRead { get; set; }

   public bool CanWrite { get; set; }

   public bool CanDelete { get; set; }

   public bool CanSchedule { get; set; }

   public bool CanDownload { get; set; }

   public bool CanOpen { get; set; }

   public bool CanMove { get; set; }

   public bool CanCopy { get; set; }

   public bool CanClone { get; set; }

   public bool CanCreateItem { get; set; }

   public Guid? CategoryId { get; set; }

   public string CategoryName { get; set; }

   public int ModifiedById { get; set; }

   public string CreatedByDisplayName { get; set; }

   public int CreatedById { get; set; }

   public string ModifiedByFullName { get; set; }

   public string ItemLocation { get; set; }

   public int ItemType { get; set; }

   public Guid Id { get; set; }

   public string CreatedDate { get; set; }

   public string ModifiedDate { get; set; }

   public DateTime ItemModifiedDate { get; set; }

   public DateTime ItemCreatedDate { get; set; }

   public Guid ReportId { get; set; }

   public string ReportName { get; set; }

   public string Name { get; set; }

   public string Description { get; set; }

}

public static List<ApiItems> GetItems()
{
   var BoldReportsURL = "https://demo.example.com"; // Provide your Bold Reports URL
   var itemType = "Report";

   using (var proxy = new CustomWebClient())
   {
     proxy.Headers["Content-type"] = "application/json";
     proxy.Headers["Authorization"] = token.token_type + " " + token.access_token; // token must be passed here
     proxy.Encoding = Encoding.UTF8;

     try
      {
         var rdata = proxy.DownloadString(new Uri(BoldReportsURL + "/reporting/api/site/site1/v1.0/items?itemType=" + itemType));
         var response = JsonConvert.DeserializeObject<List<ApiItems>>(rdata);
         return response;
      }
      catch (WebException ex)
      {
      if (ex.Response is HttpWebResponse)
         {
            var resp = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
            dynamic obj = JsonConvert.DeserializeObject(resp);
            Console.WriteLine(obj);
         }
      }
                return null;
   }
}

class CustomWebClient : WebClient
{
   protected override WebRequest GetWebRequest(Uri uri)
   {
      var request = base.GetWebRequest(uri);
      request.Timeout = 4 * 60 * 1000; //Increase time out
      if (request is HttpWebRequest)
      {
      (request as HttpWebRequest).KeepAlive = false;
      }
      return request;
   }
}