Advertisement
Guest User

Untitled

a guest
Feb 16th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from SOAPpy import SOAPProxy
  4. import sys
  5.  
  6. def createincident(params_dict):
  7.  
  8. # instance to send to
  9. instance='demo'
  10.  
  11. # username/password
  12. username='itil'
  13. password='itil'
  14.  
  15.  
  16. # proxy - NOTE: ALWAYS use https://INSTANCE.service-now.com, not https://www.service-now.com/INSTANCE for web services URL from now on!
  17. proxy = 'https://%s:%s@%s.service-now.com/incident.do?SOAP' % (username, password, instance)
  18. namespace = 'http://www.service-now.com/'
  19. server = SOAPProxy(proxy, namespace)
  20.  
  21. # uncomment these for LOTS of debugging output
  22. #server.config.dumpHeadersIn = 1
  23. #server.config.dumpHeadersOut = 1
  24. #server.config.dumpSOAPOut = 1
  25. #server.config.dumpSOAPIn = 1
  26.  
  27. response = server.insert(impact=int(params_dict['impact']), urgency=int(params_dict['urgency']), priority=int(params_dict['priority']), category=params_dict['category'], location=params_dict['location'], caller_id=params_dict['user'], assignment_group=params_dict['assignment_group'], assigned_to=params_dict['assigned_to'], short_description=params_dict['short_description'], comments=params_dict['comments'])
  28.  
  29. return response
  30.  
  31. values = {'impact': '1', 'urgency': '1', 'priority': '1', 'category': 'High',
  32. 'location': 'San Diego', 'user': 'fred.luddy@yourcompany.com',
  33. 'assignment_group': 'Technical Support', 'assigned_to': 'David Loo',
  34. 'short_description': 'An incident created using python, SOAPpy, and web
  35. services.', 'comments': 'This a test making an incident with python.nIsn't
  36. life wonderful?'}
  37.  
  38. new_incident_sysid=createincident(values)
  39.  
  40. print "Returned sysid: "+repr(new_incident_sysid)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement