Python Forum
Service Now CSV Export Redirection Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Service Now CSV Export Redirection Python (/thread-11736.html)



Service Now CSV Export Redirection Python - mavecnirp - Jul-24-2018

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.

url = "https://url.service-now.com/nav_to.do?" \
                    "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)
Any help and suggestion is much appreciated.


RE: Service Now CSV Export Redirection Python - nilamo - Jul-24-2018

Are you sure that url is right? Normally, there's only one question mark, used as a separator between the url and it's parameters. Multiple values chained together also looks weird, normally there's an ampersand separating the arguments.