I am working on a project where I need to generate almost 40 reports every month from SSRS reporting services. I have been trying to automate it using python but I am missing something in the URL that I am passing. Any insights would be much appreciated!
-
You need to show some code otherwise everyone will be guessing as to what you're missing.PGHE– PGHE2021-02-04 03:43:36 +00:00Commented Feb 4, 2021 at 3:43
-
session.auth = HttpNtlmAuth(username= '<>' , password= '<>') filename = 'C:\SSRS Reports\\report.pdf' username = "<>" password = "<>" url = "http://<>/reportserver?/report/<params>&ReportMonth=08&ReportYear=2020" r = requests.get(url, auth=HttpNtlmAuth('<>','<>' )) print(r.status_code) if r.status_code == 200: with open(filename, 'wb') as out: for bits in r.iter_content(): out.write(bits)Sia– Sia2021-02-06 18:00:00 +00:00Commented Feb 6, 2021 at 18:00
Add a comment
|
1 Answer
Your URL should consist of the following:
http://
<reportservername>/
ReportServer?/
<nameofreport>
?<param1>=<value1>&<param2>=<value2>
&rs:Format=PDF
You'd have to replace all '<...>' placeholders with your server and report information.
Here's an example: https://servername/reportserver?/SampleReports/Employee Sales Summary&EmployeeID=38&rs:Format=PDF
This sample URL simply tells SSRS to get the Employee Sales Summary report in folder /SampleReports passing the parameter EmployeeID=38 and render the report as a PDF file.
5 Comments
Sia
session.auth = HttpNtlmAuth(username= '<>' , password= '<>') filename = 'C:\SSRS Reports\\report.pdf' username = "<>" password = "<>" url = "http://<>/reportserver?/report/<params>&ReportMonth=08&ReportYear=2020" r = requests.get(url, auth=HttpNtlmAuth('<>','<>' )) print(r.status_code) if r.status_code == 200: with open(filename, 'wb') as out: for bits in r.iter_content(): out.write(bits) --I am able to get 200 from the server. Able to write the file but when I try to open the pdf file I get this..
Sia
--I am able to get 200 from the server. Able to write the file but when I try to open the pdf file I get this.."Adobe cannot open the report.pdf because it is either not a supported file type or because the file has been damaged."
reas
@Sia check your pdf file size. It may be zero bytes.
Sia
Just 1 kb. Guess it is not writing anything. Am I missing something here?
reas
Copy the URL and paste it into a browser. Are you getting a pdf back and if so does the pdf open without errors?