CSV Export Redirection Python

LB5
Kilo Explorer

I am new in python and currently working on a project and I have been stuck in exporting a table from the servicenow website using the code below, but is returning a URL redirection instead of the CSV.

Any help and suggestion is much appreciated.

 

Code:

                    "uri=server_list.do?sysparm_query=active=false%26CSV"
 
 
response = requests.get(url, stream=True, headers=headers, allow_redirects=True, verify="C:\\Users\\user\\PycharmProjects\\cert.crt")
 
LocalFilePath = "C:\\Users\\user\\Documents\\Projects\\Reporting\\server.csv"
 
 
with open(LocalFilePath, 'wb') as csv2:
    csv2.write(response.content)
1 REPLY 1

dravvyramlochun
ServiceNow Employee
ServiceNow Employee

Hello LB,

 

Maye you can check the following link which might help you:

 

https://stackoverflow.com/questions/38210813/downloading-servicenow-data-into-a-csv-file-using-pytho...

https://stackoverflow.com/questions/38210813/downloading-servicenow-data-into-a-csv-file-using-pytho...

 

Thanks,
Dravvy

Please Hit Helpful or Correct depending on the impact of the response