-3

I have this command and need to execute my program in python

curl -H 'Content-Type: application/x-ndjson' -XPOST '192.168.1.149:9200/shakespeare/doc/_bulk?pretty' --data-binary @file.json
Prophet
  • 1
  • 1

2 Answers2

0

use requests - HTTP for humans, which allows you to send any HTTP query you like

import requests
r = requests.post('192.168.1.149:9200/shakespeare/doc/_bulk?pretty', json=datadict)
print(r.text)
umläute
  • 28,885
  • 9
  • 68
  • 122
0

Try something like this:

import requests
import json

headers = {
    'Content-Type': 'application/x-ndjson',
}

params = (('pretty', ''),)

data = open('file.json', 'rb').read()
response = requests.post('http://192.168.1.149:9200/shakespeare/doc/_bulk', headers=headers, params=params, data=data)
print(response.text)

Note: This is just a example according to your curl command.

Thankyou! Hope it helps you! :)

Abdullah Ahmed Ghaznavi
  • 1,978
  • 3
  • 17
  • 27