Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rest-assured requests not working

I am using Rest-Assured to test my Rest API. the webservice seems to be running ok, since running

    curl -u "admin:admin" http://localhost:8888/users/

i get my Users as json.

then, when trying a simple request with Rest-Assured

 RestAssured.authentication = basic("admin", "admin");

  expect().statusCode(200).when().get("http://localhost:8888/users/");

gives me the output

    Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8888 refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
…

what can this be?

like image 557
danieltorres Avatar asked May 08 '12 14:05

danieltorres


1 Answers

Solved. Changed from localhost to 127.0.0.1 and it worked. It's kind of odd that both cURL/browser worked with localhost. Guess this might be a routing problem.

like image 161
danieltorres Avatar answered Nov 11 '22 19:11

danieltorres