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® Report Server by using the Get Items API. The API returns the items that match the item type and path you pass.
Which parameters does the Get Items API need?
The Bold Reports® Get Items API reads the following query parameters:
itemType - Pass the item type (Category, Reports, Dataset, Data source, or Schedule).
serverPath - The path of the category.
How do I authenticate the request?
The Report Server Get Items API needs an authentication token in the authorization header.
The authentication token must be passed in the authorization header. To obtain the authentication token, use the Authentication API or Embed Secret Key API.
Which assemblies do I need for the C# sample?
The Bold Reports® C# sample uses the following assemblies. Add them to the namespace:
System.IONewtonsoft.JsonSystem.NetSystem.Collections.GenericSystem.Text
Refer to the
Newtonsoft.Jsonassembly from the Newtonsoft.Json NuGet package.
What does a sample C# request look like?
The following C# code calls the Report Server Get Items API with the item type Report and returns the items as a list of ApiItems objects:
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<sup>®</sup> 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;
}
}Frequently asked questions
Which item types can the Get Items API return?
The Bold Reports® Get Items API returns Category, Reports, Dataset, Data source, and Schedule items. You choose the type with the itemType query parameter.
Where do I pass the authentication token?
You pass the token in the authorization header of the request. You can get it from the Authentication API or the Embed Secret Key API.