I am issuing a post request which will post a file using curl commmand from my bash automated test file (.bats) , however the request fails with an error .
The followign is the request
@test "Test 1" {
sleep 5s
TEST_URL_HTTP="http://10.15.33.230:8080/service/v1/lb"
RESPONSE=""
for x in {0..20} ;
do
echo "Sending request to $TEST_URL_HTTP"
RESPONSE=$(curl --connect-timeout 1 -s -f -X POST -H 'Content-Type: application/json' -d '@./folder/request.json' $TEST_URL_HTTP) && break
sleep 5
done
if [ $x -lt 20 ] ;
then
echo "Received echo response"
else
echo "Failed to get echo response"
exit 1
fi
}
result
[INFO] [exec] # Sending request to http://10.15.33.230:8080/service-a/v1/lb
[INFO] [exec] # $ RESPONSE=$(curl --connect-timeout 1 -s -f -X POST -H 'Content-Type: application/json' -d '@request.json' $TEST_URL_HTTP)
[INFO] [exec] # $ curl --connect-timeout 1 -s -f -X POST -H 'Content-Type: application/json' -d '@./folder/request.json' $TEST_URL_HTTP
[INFO] [exec] # curl: option -d: error encountered when reading a file
appreciate any help
thank you