python 示例请求Python ServiceNow JSONv2 - GetIncidents使用编码查询从ServiceNow使用JSONv2 Web服务获取多个事件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 示例请求Python ServiceNow JSONv2 - GetIncidents使用编码查询从ServiceNow使用JSONv2 Web服务获取多个事件相关的知识,希望对你有一定的参考价值。

import requests
from requests.auth import HTTPBasicAuth

#using local http proxy to log requests and responses
proxies = {
    "http": "http://127.0.0.1:8888",
    "https": "https://127.0.0.1:8888",
    }

auth = HTTPBasicAuth("admin", "admin")

#using an encoded query
query = "priority=1^state=1^assignment_group=8a4dde73c6112278017a6a4baf547aa7"
uri = "https://demo006.service-now.com/incident.do?JSONv2&sysparm_action=getRecords&sysparm_query=" + query
headers = {
    "accept": "application/json;charset=utf-8",
    "Content-Type": "application/json",
}

r = requests.get(url=uri, auth=auth, proxies=proxies, verify=False, headers=headers)
content = r.json()

print "Response Status Code: " + str(r.status_code)
print "Response JSON Content: " + str(content)
print "Response Incident Count: " + str(len(content['records']))

以上是关于python 示例请求Python ServiceNow JSONv2 - GetIncidents使用编码查询从ServiceNow使用JSONv2 Web服务获取多个事件的主要内容,如果未能解决你的问题,请参考以下文章

python 示例请求Python ServiceNow JSONv2 - 创建事件

python 示例请求Python ServiceNow JSONv2 - GetIncident

python 使用BeautifulSoup解析表的示例和Python中的请求

Python接口测试实战5(下) - RESTfulWeb Service及Mock Server

python Python 3.x中请求模块的一般用例错误处理示例

python Flask请求示例