Hi @Shapr0019 & @Gassim ,
I have made changes to the script you have provided.
import requests
url = "https://play.dhis2.org/2.39.0.1/api/sqlViews/jaChwoXyY1N/data.xls"
username = "admin"
password = "district"
response = requests.request("GET", url, auth=(username,password))
open('SQLViewresult.xls','wb').write(response.content)
This should work.
Thanks,
Rithvik