I am trying to automate a bulk request for Elasticsearch via Python.
Therefore, i am preparing the data for the request body as follows (saved in a list as separate rows):
data = [{"index":{"_id": ID}}, {"tag": {"input": [tag], "weight":count}}]
Then i will use requests to do the Api call:
r = requests.put(endpoint, json = data, auth = auth)
This is giving me the Error: b'{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"}],"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"},"status":400}'
I know that i need to put a newline at the end of the request, and there lies my problem: How can i append a newline to that given data structure? I tried to append '\n' to my list at the end but that didnt work out.
Thank you guys!