use pipe for curl data

Jürgen Paul picture Jürgen Paul · Sep 25, 2012 · Viewed 55.8k times · Source

I'm trying to pass the cat output to curl:

$ cat file | curl --data '{"title":"mytitle","input":"-"}' http://api

But input is literally a -.

Answer

Tom Jowitt picture Tom Jowitt · Jul 31, 2014

I spent a while trying to figure this out and got it working with the following:

cat data.json | curl -H "Content-Type: application/json" -X POST --data-binary @- http://api