import requests
# Set the request parameters
url = 'https://<instance>.service-now.com/api/now/v1/globalsearch/groups'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers )
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
url = 'https://<instance>.service-now.com/api/now/v1/globalsearch/search?sysparm_groups=2b77ce594bd6c0d901b8fbe25ceff671&sysparm_search=agent'
# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers )
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
您可以在ServiceNow平台中使用“全局文本搜索API”来获取搜索结果。首先,您需要获得可用的搜索组列表,然后发送一个包含需要搜索的组列表和搜索关键字的查询。你知道吗
下面是一个在知识库和服务目录中搜索关键字代理的示例程序。你知道吗
相关问题 更多 >
编程相关推荐