Search code examples
pythonreporting-servicespython-requestsget

Python: download a report from SQL Server Reporting Services with requests


I'm trying to get a report from SQL Server Reporting Services with the py package requests, but I'm getting the 401 error. If I access the SQL server via web, there is a pop-up asking me for user/pwd, I guess I'm failing to replicate this step via Python code.

These don't work:

url = "report-url"

requests.get(url, auth=(usr,pwd))

session = requests.Session() 
session.auth = (usr,pwd)
session.get(url)

Solution

  • There's a related thread on Microsoft Q&A discussing accessing SSRS reports over the network
    Here's another ref about SSRS URL access
    Since your sample code only implemented basic auth with the HTTP GET method I highly recommend reading the above threads cause it might be a problem related to the environment.
    If you want to take care of the pop-up, you can ref this answer about implementing a headless browser or WebKit