Using Reporting Services GetReportParameters web method

A question today on how to get the valid values for a report parameter via the web service API when a query specifies the valid values. (Whew - clunky sentence).

To do this you can use the GetReportParameters web method. First, be wary of a small bug in the documentation where the order of parameters are incorrect. Not a big problem with intellisense, though.

Example:

ReportingService rService = new ReportingService();
rService.Credentials = 
            System.Net.CredentialCache.DefaultCredentials;
 
string historyID = null;
bool forRendering = true;
ParameterValue[] values = null;                                  
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters;
 
parameters = rService.GetReportParameters
            (
                        "/Northwind Reports/Report2",
                        historyID,
                        forRendering,
                        values,
                        credentials                                           
            );

This will give you back an array of ReportParameter objects. If a ReportParameter object has a set of valid values defined by a query, reporting services will run the query and populate the ValidValues property with ValidValue objects (only when ForRendering == true). If we wanted to dump the valid values for parameter[0]:

foreach(ValidValue v in parameters[0].ValidValues)
{
    Console.WriteLine(v.Label + " " + v.Value);
}

Note, if you have hierarchical parameters, where, for example, the set of valid values for parameters[1] depends on the value selected for parameters[0], you’ll need to initialize the ParameterValue array to get the valid values for parameters[1]. If you are doing this all from scratch this may mean multiple calls to GetReportParameters.

posted on Tuesday, April 27, 2004 11:37 PM by scott

Comments

Tuesday, July 13, 2004 8:25 AM by Rajesh Jagadeesan

# re: Using Reporting Services GetReportParameters web method

Hello sir,

I tried exactly the same code, but when i executed the application, it gives the following error.

System.Web.Services.Protocols.SoapException: The permissions granted to user 'DPA32W126\ASPNET' are insufficient for performing this operation.

How do i correct this problem?

Thankx in advance,
Regards,
Rajesh Jagadeesan
Tuesday, July 13, 2004 9:02 AM by Scott Allen

# re: Using Reporting Services GetReportParameters web method

Hi Rajesh,

You'll need to setup impersonation or run the ASP.NET application under an account with permissions to the report server (is it the same machine?)

Here are some additional articles to help:

http://odetocode.com/Resources/110.aspx
http://odetocode.com/Articles/95.aspx
http://odetocode.com/Articles/123.aspx
Monday, April 25, 2005 5:18 PM by Moosa

# re: Using Reporting Services GetReportParameters web method

Hi,

I have been playing with Reporting Services for sometime now and it seems to work great so far. I am now trying to render these reports into a web application. I am using the web service to render them. However, when I try to pass my paramters, it gives an "System.NullReferenceException: Object reference not set to an instance of an object.
" exception. The following is the code I am trying to use.

ParameterValue[] parameters = new ParameterValue[3];
parameters[0].Value = "20055";
parameters[1].Value = "000047";
parameters[2].Value = "83";

Can someone please help. It seems like I am not defining my paramters correctly.

Regards.
Monday, April 25, 2005 5:50 PM by Moosa

# re: Using Reporting Services GetReportParameters web method

Actually i got it fixed. it should be like this.

ParameterValue p1 = new ParameterValue();
p1.Name = "<parameter name>";
p1.Value = "20055";

ParameterValue p2 = new ParameterValue();
p2.Name = "<parameter name>";
p2.Value = "000047";

ParameterValue p3 = new ParameterValue();
p3.Name = "<parameter name>";
p3.Value = "83";

ParameterValue[] parameters = new ParameterValue[3];
parameters[0] = p1;
parameters[1] = p2;
parameters[2] = p3;
Friday, April 21, 2006 6:14 AM by Dalia

# re: Using Reporting Services GetReportParameters web method

I am getting Error The type or namespace name 'ReportParameter' could not be found (are you missing a using directive or an assembly reference?)

please help.
Friday, April 21, 2006 6:58 AM by Scott Allen

# re: Using Reporting Services GetReportParameters web method

Dalia:
Do you have a using directive? Did you use "Add Web Reference" in Visual Studio?
Friday, April 21, 2006 11:14 AM by Dali

# re: Using Reporting Services GetReportParameters web method

Yes, I did. Now I can assign the parameters but can't display the report?
Monday, November 20, 2006 1:42 AM by Dinesh

# re: Using Reporting Services GetReportParameters web method

Hi,

Thanks for this post but still i have some dobts..........
My problem is

I am using VS2003 and Sql server 2000 RS.

It a purely windows application. and i am using RE class file in stead of.....RS web services refrence.

My problem is .that i have listed all the reports on report server.

after selecting a report, it will show all the parameter names in first checklist box...and their corresponding values in another list box.



Now problem is that if suppose report has 4 parameters.....second parameter will be inabled after selecting first and same for third. i.e.their values depend upon first parameter to be passed.

first and 4 th will be independent.



my program is showing all the parameters in first check list and the value of first parameter in the second checklist.

now i want to select a value for first parameter then it will show related value for second parameter in the second list. but my program is showing first parameter value for all the parameters...so if u know then tell me that how can i pass first parameter value so that it will fetch the values for others.



Thanks And Regards

Dinesh
dinesht15@gmail.com