I'm trying to construct a cURL config file that contains newlines in the -d
/--data
body but it doesn't seem to work the same as on the command line.
On the command line I can run:
curl -XPUT 'http://localhost:9200/mytype/_search' -d '{
"query": {
"match_all": {}
}
}'
And the data body is correctly passed along.
However, if I try to do this in a curl -K
/--config
file, it doesn't work.
test.curl:
-XPUT
-d '{
"query": {
"match_all": {}
}
}'
and then run curl -K test.curl 'http://localhost:9200/mytype/_search
and the endpoint I submit data to fails to parse. I can make it work if I put all of the data on a single line and use double quotes, but that kills some of the legibility I'm looking for.
test2.curl works
-XPUT
-d "{\"query\": {\"match_all\": {} } }"
I have also attempted to replicate this heredoc
answer: How to send line break with curl? but again it does not work in a --config
file
Instead of -d "{\"query\": {\"match_all\": {} } }"
You can do data-binary = "@requestbody.json"
Then in requestbody.json:
{
"query": {
"match_all": {}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With