I am new to shell script, I am trying to substitute an array inside an object but its not working.
I am trying to make curl request with dynamic data payload.
case $name in
"test1")
VALUE='[{"test": "1"},{"test": "2"}]'
;;
"test2")
VALUE='[{"test": "1"},{"test": "3"}]'
;;
?)
echo "Error"
exit 1
;;
esac
I am doing a curl like
$(curl -s -X POST \
"${BASE_URL}/pdc/config/add" \
-H "authorization: Bearer ${TOKEN}" \
-H "content-type: application/json" \
-d '{
"data": '\"${VALUE}\"'
}' \
--insecure
)
But this sends the array as a string.
The data to be sent should be like
{"data": [{"test": "1"},{"test": "3"}]}
But right now it is being sent as
{"data": "[{"test": "1"},{"test": "3"}]"}
How can I fix this?