- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
OK. Seriously, if you are not programming in Python you need an intervention and that is what I am here for. Look I am not asking you to change your coding language preference for everything you do, but Python makes consuming a ServiceNow Web Service so very easy. If you are writing code to consume a ServiceNow web service then try it in Python using the SUDS API. Here are some examples.
There are different libraries you can use for SOAP web service calls (and our Wiki uses SOAPpy - which isn't really supported anymore from the open source community I read) so I recommend using SUDS.
Here is the link: https://fedorahosted.org/suds/wiki/Documentation
EXAMPLE: Consuming Directly the Incident table
from suds.client import Client
WSDL_URL = 'https://yourinstance.service-now.com/incident.do?WSDL'
USERNAME = "user"
PASSWORD = "password"
# URL Detail
client = Client(WSDL_URL, username=USERNAME, password=PASSWORD)
result = client.service.get('8d6353eac0a8016400d8a125ca14fc1f') #sysid as defined in the wsdl
print 'Number for this incident is: ' + result.number
print 'Short Description for this incident is: ' + result.short_description
Result: an incident dictionary
Number for this incident is: INC0000007
Short Description for this incident is: Need access to sales db for the west
This works for any of the WSDL defined functions.
EXAMPLE: using getKeys
from suds.client import Client
WSDL_URL = 'https://yourinstance.service-now.com/incident.do?WSDL'
USERNAME = "user"
PASSWORD = "password"
# URL Detail
client = Client(WSDL_URL, username=USERNAME, password=PASSWORD)
result = client.service.getKeys(category = 'Network')
print result.sys_id
Result: a Python tuple of sys_ids
[04b1b489c0a801660075f946d6cf929c,471bfbc7a9fe198101e77a3e10e5d47f,9c573169c611228700193229fff72400,e8caedcbc0a80164017df472f39eaed1]
I know this is simple and I almost feel embarrassed sharing it, so take it for what it is worth.
I love me some Python!
For your reference here is the ServiceNow Wiki to our direct web service API:
http://wiki.servicenow.com/index.php?title=Direct_Web_Service_API_Functions
- « Previous
-
- 1
- 2
- Next »
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.