GET_USERS_URL="https://reqres.in/api/users?page=2" # Store the status code and the response HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST $GET_USERS_URL) # Extract the response body HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') # Extract the status code HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') # Print the response body echo "API response code: $HTTP_STATUS" # Print the response body echo "API response body: $HTTP_BODY" # Assert the status code if [ ! $HTTP_STATUS -eq 201 ]; then echo "Error [HTTP status: $HTTP_STATUS]" exit 1 fi