我正在努力将python脚本连接到ServiceNow票务环境。值得庆幸的是,ServiceNow有关于如何从python脚本创建票证的文档,请参阅此处的文档:
http://wiki.servicenow.com/index.php?title=Python_Web_Services_Client_Examples#gsc.tab=0
这是我用来创建故障单的脚本:
#!/usr/bin/python
from SOAPpy import SOAPProxy
import sys
def createincident(params_dict):
# instance to send to
instance='demo'
# username/password
username='itil'
password='itil'
# proxy - NOTE: ALWAYS use https://INSTANCE.service-now.com, not https://www.service-now.com/INSTANCE for web services URL from now on!
proxy = 'https://%s:%s@%s.service-now.com/incident.do?SOAP' % (username, password, instance)
namespace = 'http://www.service-now.com/'
server = SOAPProxy(proxy, namespace)
# uncomment these for LOTS of debugging output
#server.config.dumpHeadersIn = 1
#server.config.dumpHeadersOut = 1
#server.config.dumpSOAPOut = 1
#server.config.dumpSOAPIn = 1
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'])
return response
values = {'impact': '1', 'urgency': '1', 'priority': '1', 'category': 'High',
'location': 'San Diego', 'user': 'fred.luddy@yourcompany.com',
'assignment_group': 'Technical Support', 'assigned_to': 'David Loo',
'short_description': 'An incident created using python, SOAPpy, and web
services.', 'comments': 'This a test making an incident with python.\nIsn\'t
life wonderful?'}
new_incident_sysid=createincident(values)
print "Returned sysid: "+repr(new_incident_sysid)
但是,我找不到有关解决我刚使用API创建的故障单的流程的任何好文档。当我运行上面的脚本时,我得到了票号以及sys_id。
任何帮助将不胜感激。
感谢。
答案 0 :(得分:0)
显然这是一个旧的请求,但我来到这里搜索,还有400个其他人,所以这是我的解决方案:
使用server.update(sys_id="...",state="..",...)
修改记录并设置正确的值以“解析”它。
对于此方法,只有sys_id
参数是必需的,由您自己决定表单的其他字段。
P.S。 :你可以在这里找到API - https://.service-now.com/incident.do?WSDL