-1

Can someone please tell me how to use SOAP and WSDL functionality along with ServiceNow in order to download data into a CSV file. I'm using Anaconda version 3.5.2

A sample script would be really helpful

Downgrading is not an option for me.

ThatRiddimGuy
  • 381
  • 2
  • 6
  • 19
  • This is far too broad. We're not going to write your code for you. You need to read [help] and [mcve]. – Morgan Thrapp Jul 05 '16 at 19:06
  • @MorganThrapp Im sorry you feel that way. I cant find any documentation related to its use with versions 3 and above, so I asked. – ThatRiddimGuy Jul 05 '16 at 19:10
  • What about [this documentation](http://wiki.servicenow.com/index.php?title=SOAP_Direct_Web_Service_API)? That looks a lot like SOAP documentation for ServiceNow. The Anaconda version doesn't matter, it's all just Python. – Morgan Thrapp Jul 05 '16 at 19:11
  • Thanks @MorganThrapp but the Python Web Services Client Examples mentioned here use SOAPpy which is not compatible with the python version that I'm using. – ThatRiddimGuy Jul 05 '16 at 19:20
  • No, that documentation doesn't mention anything about a specific python soap library. The example does, but any SOAP library will work. Library recommendations are off topic for SO however, so I would try google. Again, you need to try some stuff on your own. – Morgan Thrapp Jul 05 '16 at 19:22
  • AFAIK, soappy is old (and arguably, so is any service still using SOAP, ugh) – Wayne Werner Jul 05 '16 at 19:22

1 Answers1

2

I also had a requirement at my work to download and process a service-now report. You can do it either using SOAP , REST or WSDL. I am using REST. Not sure if that will help.

You need to postfix download type after table name. For e.g. CSV in below example. Rest of the URL for report is same as you would download report manually from servicenow.

Here is a working code that downloads a report in CSV format. Report URL and ID will need to be changed as per your organization.

import requests
import getpass


url = "https://yourcompany.service-now.com/sys_report_template.do?CSV&jvar_report_id="1234567890abcdefg"

uname=raw_input("Enter Username: ")
pswd=getpass.getpass(prompt='Enter Password: ', stream=None)

r=requests.get(url, auth=(uname, pswd))



if r.status_code==requests.codes.ok:
    print("Requests made a connection.\n")
    f=open(r'C:\dump.csv', 'w')
    f.write(r.content)
    f.close()

else:
    print("\nAn error occured while establishing a connection.")
    print("Status code returned: ",r.status_code)

c=input("\nEnter a key to exit.\n")
Anil_M
  • 10,893
  • 6
  • 47
  • 74