We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use Secured REST API resource as SSRS data source

Thread ID:

Created:

Updated:

Platform:

Replies:

143230 Mar 11,2019 05:18 AM UTC Mar 18,2019 10:48 AM UTC ASP.NET Core 9
loading
Tags: ReportViewer
chiranjiv
Asked On March 11, 2019 05:18 AM UTC

Hi,

I want to load server reports in ReportViewer.

I need to use Secured REST API resource as SSRS data source.

I couldn't find a way to call Secured REST resource from SSRS. 

Additional information related to these are, we need to pass bearer token to REST resources since they are secured and need to authorized before access. We couldn't find a way to do the same in SSRS.

Highly appreciate if you can help on us to resolve this issue.

Thanks.


Mageshyadav M [Syncfusion]
Replied On March 11, 2019 12:02 PM UTC

Hi Chiranjiv, 
 
Please find the response for your queries. 
 
Query 
Response 
SSRS server report with rest api datasources 
We cannot change the SSRS server report datasource and we don’t have access to change. 
Syncfusion Report Server with Web API Datasource creation 
If you are trying to create the report with Web API datasource and view the report in Report Viewer means then you cane use the Syncfusion Web Report Designer with Web API.  
 
Please find the below documentation link for your reference. 
 
RDLC report with Web API datasource 
We can able to pass the Web API datasource for local saved RDL and RDLC report by setting the processing mode as local. We have prepared the simple sample in ASP.NET Core platform for your reference and it can be downloaded from below location. 
 
Please find the below kb documentation for how to create a business object datasource report. 
 
Regards, 
Mageshyadav.M 


chiranjiv
Replied On March 11, 2019 02:21 PM UTC

yes i agree with your response but i want to run server reports.

I want to use processing mode as Remote and Report Server should authorize my REST API used for report data Source.

Mageshyadav M [Syncfusion]
Replied On March 12, 2019 03:14 PM UTC

Hi Chiranjiv, 
  
Yes, your requirement is possible using extension datasource and you can authorize your Rest API in that extension. We will update you the ReportViewer sample running report server reports which has been designed in Web Designer with using WebAPI datasource on March 13, 2019 for your reference. 
  
Regards, 
Mageshyadav.M 


chiranjiv
Replied On March 13, 2019 04:57 AM UTC

Thanks it will be a great help.

chiranjiv
Replied On March 14, 2019 08:04 AM UTC

Hi,
Waiting for your response. Any updates?

Mahendran Shanmugam [Syncfusion]
Replied On March 14, 2019 02:23 PM UTC

Hi Chiranjiv, , 

Sorry for the delay. 

We are getting some issue when creating the sample with your requirement. So we will update the sample on tomorrow without fail. 

Regards, 
Mahendran S. 


Mageshyadav M [Syncfusion]
Replied On March 15, 2019 12:57 PM UTC

Hi Chiranjiv, 
 
Thanks for your patience. 
 
We have prepared the sample with WebAPI datasource and running the Report Server report in ASP.NET Core application and it can be downloaded from below location. 
 
In above sample, we have prepared the WepAPI datasource in HomeController class file as shown in below code example 
HomeController.cs 
public partial class HomeController : Controller 
    { 
        public ActionResult Index() 
        { 
            ViewBag.ServiceAuthorizationToken = this.GenerateToken("http://localhost:58065/", "test", "Test@123"); 
            return View(); 
        } 
 
        public IActionResult Error() 
        { 
            return View(); 
        } 
 
        [HttpPost] 
        public object PostParamData([FromBody]string stateCode) 
        { 
            var data = StoreSales.GetData(stateCode); 
            return data; 
        } 
 
        [HttpPost] 
        public object PostParamInt([FromBody]int id) 
        { 
            return null; 
        } 
 
        [HttpGet] 
        public object GetParamData(string stateCode) 
        { 
            var data = CustomerSales.GetData(stateCode); 
            return data; 
        } 
 
        [HttpGet] 
        public object GetData() 
        { 
            var data = StoreSales.GetData(string.Empty); 
            return data; 
        } 
 
        public string GenerateToken(string serverUrl, string userName, string password) 
        { 
            using (var client = new HttpClient()) 
            { 
                client.BaseAddress = new Uri(serverUrl); 
                client.DefaultRequestHeaders.Accept.Clear(); 
 
                var content = new FormUrlEncodedContent(new[] 
                { 
                new KeyValuePair<string, string>("grant_type", "password"), 
                new KeyValuePair<string, string>("username", userName), 
                new KeyValuePair<string, string>("password", password) 
                  }); 
 
                var result = client.PostAsync("/api/Token", content).Result; 
                string resultContent = result.Content.ReadAsStringAsync().Result; 
                var token = JsonConvert.DeserializeObject<Token>(resultContent); 
 
                return token.token_type + " " + token.access_token; 
            } 
        } 
    } 
 
Please find the below steps for how to use the WebAPI datasource in Report server. 
 
Step 1: Run the above attached sample. 
 
Step 2: Copy the URL for that sample as shown in below snap since we have created WebAPI datasource in same sample. 
 
 
Step 3: Open the Web report designer from server, create new datasource, choose WebAPI option and pass the above copied URL as shown in below code example. 
 
 
 
Step 4: Go to dataset dialog and provide the method in Web API datasource as shown in below snap. For reference on how to form the query, please refer this help link,  
 
 
 
Step 5 : Create any report item with dataset fields and save that report in report server. 
Step 6: Stop the above running sample. 
Step 7: Pass your Report server URL, newly created report path and Service authorization token as shown in below code example. 
Index.cshtml 
@{ 
    ViewData["Title"] = "ReportViewer ASP.NET CORE Support"; 
} 
<style> 
    body, html, #reportviewer { 
            overflow: hidden !important; 
            height:100%; 
            width:100%; 
        } 
</style> 
<ej-report-viewer id="reportviewer" report-service-url="http://localhost:58065/ReportService/api/viewer" report-path="/webapi/WebAPITest" service-authorization-token="@ViewBag.ServiceAuthorizationToken" ></ej-report-viewer> 
<ej-script-manager></ej-script-manager> 
 
Step 8: Pass your Report server URL, Username and password to get the service authorization token in HomeController class file as shown in below code example. 
HomeController.cs 
    public partial class HomeController : Controller 
    { 
        public ActionResult Index() 
        { 
            ViewBag.ServiceAuthorizationToken = this.GenerateToken("http://localhost:58065/", "test", "Test@123"); 
            return View(); 
        } 
 
        public IActionResult Error() 
        { 
            return View(); 
        } 
 
We have prepared the simple RDL with above sample Web API datsource and it can be downloaded from below location. Could you please add this RDL in your report server and run the sample with that report path. 
 
Regards, 
Mageshyadav.M 


chiranjiv
Replied On March 18, 2019 05:09 AM UTC

Thank you so much

Mageshyadav M [Syncfusion]
Replied On March 18, 2019 10:48 AM UTC

Hi Chiranjiv, 
  
Thanks for your acknowledgment. 
  
Please let us know in case of any queries in provided solution. 
  
Regards, 
Mageshyadav.M 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon