I 'd like to post directly a json object from a url(json) to another url
so the command goes as follows:
curl "<resource_link>.json" -o sample.json
curl -X POST "<my_link>" "Content-type: application/json" -d @sample.json
I 'd like to avoid this, so what is the solution? Is it something like that?
curl -X POST "<my_link>" "Content-type: application/json" -d "curl <resource_link>.json"
But it does not work? Also, this one post Stream cURL response to another cURL command posting the result does not explain thouroughly and it is not working Yes,
curl
manual explains the '@' but it does not explain about using another curl Alternatievely, if I could save somewhere temporarily the 1st cURL response and use it in the other command(but not in a file)
-x POST
in there so let's start with dropping that.-o
, or telling -o
to use stdout with -o-
, and-d@-
.curl "<link>.json" | curl "<link2>" -H "Content-type: application/json" -d @-
Starting with curl 7.82.0 you can do it even easier with the new --json
option:
curl "<link>.json" | curl "<link2>" --json @-