0

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!

2
  • You need to show some code otherwise everyone will be guessing as to what you're missing. Commented 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) Commented Feb 6, 2021 at 18:00

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

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..
--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."
@Sia check your pdf file size. It may be zero bytes.
Just 1 kb. Guess it is not writing anything. Am I missing something here?
Copy the URL and paste it into a browser. Are you getting a pdf back and if so does the pdf open without errors?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.