I have a some url array like below, Later I want to do some post method for each array element. somehow array element not working, but when I try direct url value its working.
# Print the uncommon URLs
echo "Uncommon URLs:"
printf "%sn" "${uncommon_urls[@]}"
IFS=$'n' read -d '' -r -a array1 <<< "${uncommon_urls[@]}"
getApp=$(curl -X GET -H "$headers" -H "Content-Type: application/json" "$uri")
#echo $getApp
for url in "${array1[@]}"; do
echo $url
url=$(echo "$url" | rev | cut -c2- | rev)
echo $url
url=$(echo "$url" | tr -d '"')
echo $url
#getApp=$(echo "$getApp" | jq '.redirect_uris -= ["https://172.16.19.31:1111/login/callback"]')
getAppnew=$(curl -X PUT -H "$headers" -H "Content-Type: application/json" -d "$getApp" "$uri")
done
echo urslnew
echo $getAppnew
output
Uncommon URLs:
[
"https://172.xx.xx.31:3610/login/callback",
"https://172.xx.xx.31:3611/login/callback",
]
"https://172.xx.xx.31:3611/login/callback",
"https://172.xx.xx.31:3611/login/callback"
https://172.xx.xx.31:3611/login/callback
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3411 0 1597 100 1814 2321 2636 --:--:-- --:--:-- --:--:-- 4950
"https://172.xx.xx.31:3612/login/callback",
"https://172.xx.xx.31:3612/login/callback"
https://172.xx.xx.31:3612/login/callback
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3411 0 1597 100 1814 3013 3422 --:--:-- --:--:-- --:--:-- 6423
Code which is working is below.If I put url value directly, its working
getApp=$(echo "$getApp" | jq '.redirect_uris -= ["https://172.xx.xx.31:1111/login/callback"]')