Привет
Следующая команда curl работает, и я пытаюсь опубликовать то же самое (с другими данными JSON), используя requests.post
и показывая приведенную ниже ошибку. Любое руководство о том, что не так?
curl -vk "https://splunk-hec.company.com:8088/services/collector" -H "Authorization: {token id }" -d '{"sourcetype": "source","index":"indexname", "event": {"a": "value1", "b": ["value1_1", "value1_2"]}}'
КОД ПИТОНА: -
_raw = {
"Total_radar_count":"999",
"Analyze":{
"Screen":{"count":110,"radar_link":"change://problem/50411162&42639456&44776863&43703933"},
"Investigate":{"count":065,"radar_link":"change://problem/50411162&42639456&44776863&43703933"},
"Review":{"count":106,"radar_link":"change://problem/50411162&42639456&44776863&43703933"}
},
"timestamp": int(time.time()) # Can also use datetime.datetime.now().isoformat()
}
url = 'https://splunk-hec.company.com:8088/services/collector?sourcetype=source?index=indexname'
json = _raw
auth_token = 'token id'
head = {'Authorization': auth_token}
response = requests.post(url, json=json, headers=head)
print(response)
print (response.reason)
print(response.json())
ОШИБКА: -
<Response [400]>
Bad Request
{u'text': u'No data', u'code': 5}