由于我看不到任何关于如何正确使用sysparm_query_category的参考,我可以确认您是如何在get请求中附加sysparm_query_category的吗?
在代码行下面添加。我希望有人能帮助和指导我,因为我是新来的ServiceNow。谢谢!
from pysnow import Client
...
resource = self.client.resource(api_path=F"/table/{table}")
resource.parameters.add_custom({"sysparm_query_category": "cat_read_generic"})
request = resource.get(query=query, fields=fields)https://developer.servicenow.com/dev.do#!/reference/api/sandiego/rest/c_TableAPI
发布于 2022-04-22 06:57:45
我不知道pysnow API。我希望这能帮到你。否则请参考上面的评论。
#Need to install requests package for python
#easy_install requests
import requests
# Set the request parameters
url = 'https://demonightlycoe.service-now.com/api/now/table/incident?sysparm_query=category%3Dcat_read_generic&sysparm_limit=1'
# 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)发布于 2022-04-22 21:30:10
在检查和测试之后,我们可以使用add_custom
client.parameters.add_custom({'foo': 'bar'})这将是像&foo=bar https://pysnow.readthedocs.io/en/latest/usage/parameters.html这样的参数之外的附加参数。
https://stackoverflow.com/questions/71839715
复制相似问题