Issue
Could someone tell me how to pass the output of one CURL GET to another CURL POST? I mean something like this:
curl --header "Content-Type: application/json" --request POST --data "{\"specification\": curl --header "Content-Type: application/json" --request GET "https://user:pass@anotherhost"}" "https://user:pass@localhost"
Solution
Use jq
to craft JSON in the shell.
response="$(curl --header "Content-Type: application/json" --request GET "https://user:pass@anotherhost")"
data="$(jq "{specification: .}" <<< "$response")"
curl --header "Content-Type: application/json" --request POST --data "$data" "https://user:pass@localhost"
Keep in mind, that passwords in command line arguments are public to the host.
Answered By - ceving