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

How to dynamically set the Service Url field of a Web Service Data Source

14 Answers 1542 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 18 Oct 2018, 10:35 PM

Have a Web Service Data Source in the Report Designer.  Want to set the Service Url field dynamically based on report parameter passed in.  Is this possible?  That field doesn't have an Expression option.  It's just a text field...

 

14 Answers, 1 is accepted

Sort by
0
Edward
Top achievements
Rank 1
answered on 19 Oct 2018, 08:48 PM
Was going about this the wrong way initially- using the Report Designer... instead of using the Report Library and defining my own reports with access to underlying C# classes and api's.  This would give me better controls and accessibility. 
1
Silviya
Telerik team
answered on 23 Oct 2018, 10:43 AM
Hello Edward,

I suggest to provide the Service Url as an inline parameter, i.e Service Url property of the WebServiceDataSource can be set as an inline parameter @Url, and then the value of @Url can be provided as an Expression (i.e. taken from a Report Parameter) so that its value to be evaluated run time. Please refer to this screen shot - https://www.screencast.com/t/jtcgJ2EAK

Regards,
Silviya
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Marius
Top achievements
Rank 1
answered on 18 Oct 2019, 07:06 AM

Hi,

If you see in your screenshot it says "Invalid URI: The hostname could not be parsed" .. It should use the Design-time Value.

This aside, exactly the same message I get in the web viewer:

An error has occurred while processing Table 'table1':
Invalid URI: The hostname could not be parsed

 

0
Todor
Telerik team
answered on 22 Oct 2019, 01:41 PM

Hi Marius,

Which version do you use? There is a known problem with our latest official release 13.2.19.918 related to WebServiceDataSource. It has been fixed in the Internal Build 13.2.19.1004 - 'WebServiceDataSource - Parameters are not correctly evaluated during processing'. You may upgrade to the Latest Internal Build.

Regards,
Todor
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tally
Top achievements
Rank 1
answered on 28 Oct 2019, 08:11 AM

I am trying to implement the inline url, and have 2 problems:

1. It does not work

2.I need to concat the controller's method name to the url, different to each service data source.

when I see the service url it is written as "@url" (attached picture of the parameters in the report, and the result on the server)

angular client side code:

let rs = {
      report: this.reportName,
      authenticationToken: token,
      parametersAreaVisible: false,
      parameters: {
        Url:'http://localhost:52913/api/alarms/'
      }
    } as unknown as JSON;

When I want to concat Url with method name do I do it on the parameters form like:

value= Parameters.Url,Value+"myMethodName

or on the ServiceUrl property like : @url myMethodName

maybe i need some brackets?

TX

Tally

0
Tally
Top achievements
Rank 1
answered on 28 Oct 2019, 10:07 AM

OK I got it to work:

I had my own code problems, to make the problems above.

1. Add a parameter to the whole report, to represent the Url, lets call it Url

2. On the client side:angular client side code:
let rs = {
      report: this.reportName,
      authenticationToken: token,
      parametersAreaVisible: false,
      parameters: {
        Url:'http://localhost:52913/api/alarms/'
      }
    } as unknown as JSON;

3.add an inline parameter to each web service data source. Name: @Url Type: inline Value: = Parameters.Url.Value +'myMethodName'

4.set the service url of this web service data source to @Url

 

Hope I have helped.

 

0
Thanh
Top achievements
Rank 1
answered on 25 Nov 2019, 07:51 AM

I'm using Telerik Reporting R3 2019 but still error: "Invalid URI: The hostname could not be parsed"

 

0
Todor
Telerik team
answered on 27 Nov 2019, 01:50 PM

Hello Thanh,

The problem you experience may be due to a known issue with version 13.2.19.918. The problem is fixed in the Service Pack - version 13.2.19.1030 - Fixed-Web Service Data Source-Parameters are not correctly evaluated during processing. Test to upgrade to our latest version and check whether the problem will be fixed.

Regards,
Todor
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Thanh
Top achievements
Rank 1
answered on 28 Nov 2019, 03:42 PM
Thank you!
0
Shawn
Top achievements
Rank 1
answered on 23 Jan 2020, 02:32 PM

I have a slightly different scenario, but still along the same lines as this.

Our reports use WebServiceDataSource with the Service URL defined as @Url and at run-time this value set using the DataSource parameter passed into the report form our web page.  (i.e. = Parameters.DataSource.Value).  This all works fine.  The DataSource value would be:  

https://<domain>/api/Reports/v1.0/Security

 

Our reports also include parameters, one of which is a list of customer sites.  So I created another WebServiceDataSourcecalled dsSitesParam and set the Service URL to @Url1.  The API would be similar to the DataSource value except the 'Security' text would be replaced with 'Sites', so at run-time we are using the same DataSource paramater but using the Replace function to change the 'Security' to 'Site'.  (i.e. = Replace(Parameters.DataSource.Value,"Security","Sites")

At design time when using the hard-coded path to the Sites api and can download the site just fine.  See screenshot dsSitesParam.

 

The reports also have a Sites parameter.  When using a CSV Data Source for this parameter, it works fine.  When I set it to use the dsSitesParam data source, the report fails to load with the following error:

 

Invalid URI: Hostname could not be parsed

 

Should I be able to use the Replace function of the DataSource value to change it to the correct API to be used for getting the list of sites?

 

1
Todor
Telerik team
answered on 28 Jan 2020, 09:27 AM

Hi Shawn,

I tested the described scenario as I understood it and can confirm that you may use the Replace function when setting the WebServiceDataSource Url through an Expression. I have attached a demo report with the Web API project exposing the data services. The data services run on 'http://localhost:50160/api/data' and 'http://localhost:50160/api/site'. The parameter 'Parameter1' has AvailableValues coming from 'webServiceDataSource2', which Url is set with:

= Replace(Parameters.Url.Value,"data","site")

I suspect that there is something inaccurate in the final Url. You may use Fiddler to access the exact requests to check this.

Regards,
Todor
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Shawn
Top achievements
Rank 1
answered on 28 Jan 2020, 09:52 AM

Todor,

Thank you for the reply.  After some further testing and moving things around it came down to the order in which the parameters were being defined.  I was trying the process the 'Sites' parameter which was using the 'Replace' function on a parameter ('DataSource') that was not yet defined.  So I moved the 'Sites' parameter down the list so that it was being defined after the 'DataSource' parameter.

Working fine now.

Regards,

Shawn

0
omar
Top achievements
Rank 1
Veteran
answered on 02 Sep 2020, 08:17 PM
[quote]Todor said:

Hi Marius,

Which version do you use? There is a known problem with our latest official release 13.2.19.918 related to WebServiceDataSource. It has been fixed in the Internal Build 13.2.19.1004 - 'WebServiceDataSource - Parameters are not correctly evaluated during processing'. You may upgrade to the Latest Internal Build.

Regards,
Todor
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
[/quote][quote]Todor said:

Hi Marius,

Which version do you use? There is a known problem with our latest official release 13.2.19.918 related to WebServiceDataSource. It has been fixed in the Internal Build 13.2.19.1004 - 'WebServiceDataSource - Parameters are not correctly evaluated during processing'. You may upgrade to the Latest Internal Build.

Regards,
Todor
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

[/quote]

Hello Todor
I am on version 14.1.20.618. Is this still a problem b/c i am getting it? I followed Silviya's example and i get data appearing when i go through the Configure Web Service Data Source, however, i still get this error. 

 

0
Todor
Telerik team
answered on 08 Sep 2020, 11:44 AM

Hello omar,

The issue is fixed and should not occur in version 14.1.20.618. Can you send us a runnable report that demonstrates the problem? For example, you may open a support ticket and attach the project there.

Regards,
Todor
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Report Designer (standalone)
Asked by
Edward
Top achievements
Rank 1
Answers by
Edward
Top achievements
Rank 1
Silviya
Telerik team
Marius
Top achievements
Rank 1
Todor
Telerik team
Tally
Top achievements
Rank 1
Thanh
Top achievements
Rank 1
Shawn
Top achievements
Rank 1
omar
Top achievements
Rank 1
Veteran
Share this question
or