Unexpected character while posting a payload to elastic search via rest client


Hi, I am using 7.17.3 stack for elastic. Low level Elasticsearch rest client is from 7.15.2
I am trying to send a payload having special characters in it using the below code.

Request request = new Request("PUT", ELASTIC_ENDPOINT + elasticUniqueID);
request.setEntity(new NStringEntity(message, ContentType.APPLICATION_JSON));

I am some time getting this error -
ine [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason
":"failed to parse","caused_by":{"type":"i_o_exception","reason":"Unexpected character (',' (code 44)): expected a value
n at [So
urce: (ByteArrayInputStream); line: 1, column: 2803]"}},"status":400}

How I can write any type of string using the simple JSON object?

It seems its trying to combine 2 jsons while sending request and hence getting , between those 2 jsons. How I can force it to post single json at a time?

it was my kafka giving multiple jsons to it. can be closed.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.