I have a web service that expects some parameters. I want to pass one of these parameters (named "data") to curl via stdin. I tried
echo -n "some data" | curl -d x="foo" -d y="bar" -d data=@- "http://somewhere"
which doesn't work, as the value of data then is "@-" instead of "some data".
Is it possible to use the @ in curl to associate the input from stdin with a specific parameter?
edit: My goal is to chain multiples web services so the data I pass will be the output of another curl call.
Use -d @-
E.g.:
echo '{"text": "Hello **world**!"}' | curl -d @- https://api.github.com/markdown
Output:
<p>Hello <strong>world</strong>!</p>
Is this not possible?
curl -d x="foo" -d y="bar" -d data="@some data" "http://somewhere"
Or
curl -d x="foo" -d y="bar" -d data="@$(echo "some data")" "http://somewhere"
echo "some data"
can be another command or file input: $(<somefile)
.
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