Guest User

Untitled

a guest
Apr 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. class Change(Base):
  2. __table__ = 'change_request.do'
  3.  
  4. # Fetch changes updated on the last 5 minutes
  5. changes = chg.last_updated(minutes=5)
  6. #print changes client side script.
  7.  
  8. for eachline in changes:
  9. print eachline
  10.  
  11. Traceback (most recent call last):
  12. File "C:Python27libsite-packagesSOAPpyParser.py", line 1080, in _parseSOAP
  13. parser.parse(inpsrc)
  14. File "C:Python27Libxmlsaxexpatreader.py", line 107, in parse
  15. xmlreader.IncrementalParser.parse(self, source)
  16. File "C:Python27Libxmlsaxxmlreader.py", line 125, in parse
  17. self.close()
  18. File "C:Python27Libxmlsaxexpatreader.py", line 220, in close
  19. self.feed("", isFinal = 1)
  20. File "C:Python27Libxmlsaxexpatreader.py", line 214, in feed
  21. self._err_handler.fatalError(exc)
  22. File "C:Python27Libxmlsaxhandler.py", line 38, in fatalError
  23. raise exception
  24. SAXParseException: <unknown>:1:0: no element found
  25.  
  26. from servicenow import ServiceNow
  27. from servicenow import Connection
  28. from servicenow.drivers import SOAP
  29.  
  30. # For SOAP connection
  31. conn = SOAP.Auth(username='abc', password='def', instance='test')
  32.  
  33. rpt = ServiceNow.Base(conn)
  34. rpt.__table__ = "sys_report_template.do?CSV"
  35.  
  36. #jvar_report_id replaced with .... to protect confidentiality
  37. report = rpt.fetch_one({'jvar_report_id': '92a6760a......aas'})
  38.  
  39. for eachline in report:
  40. print eachline
  41.  
  42. import requests
  43. import json
  44.  
  45. # Set the request parameters
  46. url= 'https://myinstance.service-now.com/sys_report_template.do?CSV&jvar_report_id=929xxxxxxxxxxxxxxxxxxxx0c755'
  47. user = 'my_username'
  48. pwd = 'my_password'
  49.  
  50. # Set proper headers
  51. headers = {"Accept":"application/json"}
  52.  
  53. # Do the HTTP request
  54. response = requests.get(url, auth=(user, pwd), headers=headers )
  55. response.raise_for_status()
  56. print response.text
  57.  
  58. f=open(r"C:pythonmyoutputMy_sn_Report.csv", "w")
  59.  
  60. print (response.text, file=f)
  61. f.close()
Add Comment
Please, Sign In to add comment