gpt4 book ai didi

python - 使用 python 的 Splunk REST Api : 201 with curl, 404?

转载 作者:太空宇宙 更新时间:2023-11-03 16:35:23 24 4
gpt4 key购买 nike

我正在尝试向 Splunk REST Api 发出请求。使用curl 调用Api 时效果非常好:

curl -k  https://host:8090/services/collector/event -H "Authorization: Splunk AUTH_CODE" -d '{"event":"Hello, World!","source":"Airwatch","index":"client-myclient"}'
{"text":"Success","code":0}%

但是当我尝试在 python 中提取相同的请求时,我收到 404 错误:

splunkhost = 'MY_IP'
splunkUrl = 'https://%s:8090/services/collector/event' % splunkhost
splunkData = {'index':'client-myclient','event':'Event Python Test'}
splunkResponse = requests.get(splunkUrl, headers={'Authorization': 'Splunk AUTH_CODE'}, data = splunkData, verify=False)
print splunkResponse.text

/Library/Python/2.7/site-packages/requests/packages/urllib3/connectionpool.py:789: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning)
{"text":"The requested URL was not found on this server.","code":404}

我知道不安全警告来 self 的 verify=false。 header 似乎通过了(splunkResponse.erquest.headers 正确显示它们),而我的不同测试没有给出任何内容...

我错过了什么?

最佳答案

事实证明,当 python 是 GET 请求时,curl 是一个 POST 请求。已解决。

关于python - 使用 python 的 Splunk REST Api : 201 with curl, 404?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37271794/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com