This is a migrated thread and some comments may be shown as answers.

Angular Report Viewer wrapper - Dynamically setting serviceUrl

1 Answer 406 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arthur
Top achievements
Rank 1
Arthur asked on 03 Aug 2020, 10:15 PM

Good day,

I hope you can help me as I am battling getting the report viewer that is working well in another html/javascript project.

Now converting the application to Angular (8).

This loads the report viewer fine:

  <tr-viewer #viewer1 
  [containerStyle]="viewerContainerStyle"
  [serviceUrl]="http://localhost/RepService/ReportViewer/api/reports"
  [templateUrl]="'http://localhost/RepService/ReportViewer/templates/telerikReportViewerTemplate.html'"
  [viewMode]="'INTERACTIVE'"
  [scaleMode]="'SPECIFIC'"
  [scale]="1.0"
  >
</tr-viewer>

 

But this would need to be reconfigured when deploying, so to do that, this get's the closest:

In html file:

  <tr-viewer #viewer1 
  [containerStyle]="viewerContainerStyle"
  [serviceUrl]="serviceUrl"
  [templateUrl]="'http://localhost/RepService/ReportViewer/templates/telerikReportViewerTemplate.html'"
  [viewMode]="'INTERACTIVE'"
  [scaleMode]="'SPECIFIC'"
  [scale]="1.0"
  >
</tr-viewer>

 

In .ts file:

ngAfterViewInit() {
    this.serviceUrl = "'http://localhost/RepService/api/reports/'";

 

But getting the following:

The serviceUrl is not specified.

 

When I move that line to ngOnInit:

ngOnInit() {
    this.serviceUrl = "'http://localhost/XRSReportingService/api/reports/'";

Getting: Cannot access the Reporting REST service. (serviceUrl = ''http://localhost/XRSReportingService/api/reports/''). Make sure the service address is correct and enable CORS if needed. (https://enable-cors.org)

 

So this doesn't look like a CORS issue to me.

Thanks very much

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 06 Aug 2020, 07:48 PM

Hello Arthur,

Could you please check if you can successfully access http://localhost/XRSReportingService/api/reports/

The error indicates that the specified service is not functional. I suspect that the serviceUrl is not set properly. Please, notе that in Angular viewer the service should be provided with the absolute URL, as Angular application cannot host the REST Service.

You can also use Fiddler to check the requests and send us the SAZ file if the issue is not resolved.

Regards,
Neli
Progress Telerik

Tags
General Discussions
Asked by
Arthur
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or