2016-05-17 84 views
1

我正在嘗試請求反對Splunk REST Api。Splunk REST Api:201捲曲,404與python?

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錯誤:調用帶有捲曲的API時,它的工作原理馬麗娟

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} 

我明白了不安全的警告來自於我驗證=假。標題似乎通過(splunkResponse.erquest.headers正確顯示),並且我的不同測試沒有給出任何東西...

我錯過了什麼?

回答

1

原來,當python是GET的時候,curl是一個POST請求。解決了。