Here is the curl which works perfectly fine
curl --user "A:B" --digest --header "Accept: application/json" --header "Content-Type: application/json" --request POST "http://localhost:8080/api/private/foo/bar" --data '["123456"]'
I wanted to run this in a for loop so I wrote this code
Orgs=(
"123456"
"333444"
)
for i in ${Orgs[@]}
do
curl --user "A:B" --digest --header "Accept: application/json" --header "Content-Type: application/json" --request POST "http://localhost:8080/api/private/foo/bar" --data '"["\"${i}\""]"'
done
However this does not work since --data is not well formatted. The single quotes are needed in curl to send data --data '["123456"]' but single quotes, are not working as expected in shell script.
How can I fix my curl in shell script to work out ?