Generate report from URL - SQL Server Reporting Services 2008
Asked Answered
F

5

14

I have SQL Server Reporting Services 2008 and when I open the following URL:

"http://localhost/Reports/Pages/Report.aspx?someReport"

I'm getting report screen in which I fill my parameters and generate a report,

My question is how can I do this without any GUI? by batch file or C# script..

Thanks in advance.

=========================================================================

EDIT:

Thanks to all answer above I succeed to generate a report and save it as an XML using the following link:

"http://Server/ReportServer/Pages/ReportViewer.aspx?someReport&dFrom=01/01/2012&dTo=08/08/2012&rs%3AFormat=XML"

Thanks for you all!!!

Fears answered 7/8, 2012 at 12:30 Comment(2)
You need to apply this to the reportserver not the reports page. server/reportserverJoeyjoffre
have you tried what I posted - I am quite certain that is your issue.Joeyjoffre
J
16

Your problem is you are passing parameters to http://server/reports... you need to pass parameters to http://server/reportserver...

I remember this issue I had when I first started using Reporting Services.

Here's the MSDN that may help you: http://msdn.microsoft.com/en-us/library/ms155391.aspx

For example, to specify two parameters, “ReportMonth” and “ReportYear”, defined in a 
report, use the following URL for a native mode report server:

http://myrshost/ReportServer?/AdventureWorks 2008R2/Employee_Sales_Summary_2008R2&ReportMonth=3&ReportYear=2008

The result is like so:

http://myRSServer/ReportServer/Pages/Report.aspx?%2fDefaultTenant%2fDialing+Reports%2fDialing+Agent+Performance&dFrom=01/01/2012&dTo=08/08/2012

If you want to export the report to excel / pdf / etc you can append it:

For excel: &rs:Format=Excel

For PDF: &rs:Format=PDF

This should help as well: http://www.mssqltips.com/sqlservertip/1336/pass-parameters-and-options-with-a-url-in-sql-reporting-services/

Joeyjoffre answered 7/8, 2012 at 14:54 Comment(3)
what am i doing wrong with this URL: win-t8o9hquvjcf/Reports/Pages/… It just stays blankLani
Your first parameter should start with a ? not a &. Its any additional parameters need an &.Joeyjoffre
i get this if i use a ? '/DatasheetforOMManual?ProjectReference=65656' is not valid.Lani
G
1

Your second URL option is the closest, you pass the date parameters without quotes. As JonH states you want to use ReportServer instead of Reports, and you also want to remove ItemPath=

http://Server/ReportServer/Pages/Report.aspx?%2fDefaultTenant%2fDialing+Reports%2fDialing+Agent+Performance&dFrom=01/01/2012&dTo=08/08/2012

Additionaly, if you want to export the file you can append &rs:command=render&rs:format=PDF replacing PDF with the format you desire

Gruesome answered 7/8, 2012 at 15:20 Comment(0)
S
0
string URL = "YourReportUrl";     
string FullURL = URL + "&JobId=" + JobId.ToString() + "&JobNumber=" + JobNo.ToString() + "&rs%3aCommand=Render";

Where JobId and JobNumber will be your Parameter names. This will directly open in your report Viewer.

To display in XML format, add this &rs%3AFormat=XML to end of URL.

string FullURL = URL + "&JobId=" + JobId.ToString() + "&JobNumber=" + JobNo.ToString() + "&rs%3aCommand=Render&rs%3AFormat=XML";
Suggestibility answered 7/8, 2012 at 12:59 Comment(2)
Try without quotes with your First option. Also refer this link for more info on Date parameter stuff - msdn.microsoft.com/en-us/library/ms155064Suggestibility
@HarshaHerle that link shows how to pass language not anything about dates. I believe the issue has to do with passing the parameters to an incorrect URL. You cannot pass the parameters to the standard GUI, you have to pass them to the reportserver see my answer.Joeyjoffre
A
0

Following is an example for using URL for a report. It passes parameters and also specify whether the parameters should be hidden or not

http://myServer/ReportServer/Pages/ReportViewer.aspx?/InventoryTracking/Receiving/InboundContainerID
&rs:Command=Render&rc:Parameters=false&Plant="20"

If are using HTML file to display this, then use

window.location.href = url;
Anana answered 16/4, 2014 at 15:4 Comment(0)
O
0

I have been trying to do this via POST but it doesn't work properly. What am I doing wrong? Note that this request is hardcoded because I copied it from Postman. It does work over Postman, but NOT over HttpClient. HttpClient GET works but because of an url being too big, we can't use GET and have to switch to POST.

            var request = new HttpRequestMessage(HttpMethod.Post, "validBaseUrlToReportServer/ReportServer/ReportService2010.asmx?/ArticlesV1&rs:Format=Excel&rs:Command=Export");
            var content = new StringContent("{\r\n    \"DateFrom\": \"2024-08-01\",\r\n    \"ArticleType_DDL\": \"1\",\r\n    \"DateTo\": null,\r\n    \"ArticleCategory_Tree_DDL_Nullable\": \"[64,65,67,66]\"}", null, "application/json");
            request.Content = content;
            var response = await httpClient.SendAsync(request);
            response.EnsureSuccessStatusCode();
Overhead answered 1/8 at 17:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.