Reputation: 2347
Hello I an trying to add data to my elasticsearch on my localhost. I found and example of post request:
data = {"key": "value", 'time_utc': time.strftime('%Y-%m-%dT%H:%M:%S')}
print data
r = requests.post('http://localhost:9200/macs/', json.dumps(data))
print r
But this give error(<Response [400]>
) and I am not understanding why.
Can someone help ?
Upvotes: 1
Views: 1511
Reputation: 36
requests.post('http://localhost:9200/macs/', data=json.dumps(data),headers={'Content-Type': 'application/json'})
Upvotes: 1