0

The following cURL command is working:

curl -XPOST http://localhost:9200/test/test -d '{"name":"John", "age":31}' -H 'Content-Type: application/json'

However, when I execute the following command:

curl -XPOST http://localhost:9200/test/test -d '/mnt/c/path/to/filename/test.json' -H 'Content-Type: application/json'

I receive the following error:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"not_x_content_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}},"status":400}

This is kind of weird since the content of this 'test.json' is exactly the same as in the first command. Namely: A compressed version of: '{"name":"John", "age":31}'.

1 Answer 1

1

When sending a file you need to use the --data-binary flag instead of -d:

curl -XPOST http://localhost:9200/test/test --data-binary @'/mnt/c/path/to/filename/test.json' -H 'Content-Type: application/json'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.