Can't insert variable with two headers in curl Can't insert variable with two headers in curl curl curl

Can't insert variable with two headers in curl


You need to use an array, at which point you can put all the headers in the array and simplify your call.

#!/usr/bin/env bashvalue_for_header="value"headers=(  -H "custom1: ololo1"  -H "custom2: ololo2"  -H "Content-Type: application/json"  -H "custom_ololo: $value_for_header")curl -X "PUT" "${headers[@]}" http://localhost:8000/ -d '{"a": true}' -vv


You need to put $headers into ""

curl -X "PUT" -H "Content-Type: application/json" -H "custom_ololo:  $value_for_header" "$headers" http://localhost:8000/ -d '{"a": true}' -vv