码迷,mamicode.com
首页 > Web开发 > 详细

通过iTop Webservice接口丰富OQL的功能

时间:2016-05-25 14:42:54      阅读:405      评论:0      收藏:0      [点我收藏+]

标签:

通过Python调用iTop的Webservice接口:

#!/usr/bin/env python
#coding: utf-8
import requests
import json

itopurl = "https://itsm.google.cn/webservices/rest.php"
# opr = json.dumps(
#     {‘operation‘:‘list_operations‘}
# )
opr = json.dumps(
    { operation:core/get,
      class: FunctionalCI,
      key:"SELECT FunctionalCI",
      output_fields : name , contacts_list}
)
payload={
    "version":"1.0",
    "auth_user":"admin",
    "auth_pwd":"your_pwd",
    "json_data":opr
}
r = requests.post(url=itopurl, data=payload)
dict_r = json.loads(r.content)
fp = open("server.csv","w+")
for item in dict_r[objects]:
    if len(dict_r[objects][item][fields][contacts_list]) == 0:
        # print dict_r[‘objects‘][item][‘fields‘][‘name‘]
        fp.write(dict_r[objects][item][fields][name] + "\n")
fp.close()

 

 

https://sourceforge.net/p/itop/discussion/922361/thread/0c0ad12f/

https://wiki.openitop.org/doku.php?id=advancedtopics:rest_json

http://www.07net01.com/program/2016/02/1304701.html

通过iTop Webservice接口丰富OQL的功能

标签:

原文地址:http://www.cnblogs.com/IvanChen/p/5526739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!