6

This is very basic and simple question regarding Rest-assured framework. I have been trying to connect to weather webservice api using some param. But i kept getting connection refused. I could not find out what actually the URL that rest-assured trying to connect with.

given().
        param("APPID","xxxxxx").
        param("q","London").
    get(EndPoint.GET_ENDPOINT).
        then().
            statusCode(200).
                log().everything();

Getting this: java.net.ConnectException: Connection refused.

I would like to print out the connection URL in my console. Do you have any idea how?

user1459497
  • 659
  • 2
  • 9
  • 18

2 Answers2

9

Move the .log().all() part to the `.given()̀ part, it should print it out to the console:

given().log().all()
  .param(…)…
Skippy le Grand Gourou
  • 6,976
  • 4
  • 60
  • 76
Gergely A.
  • 404
  • 3
  • 6
  • This can be chained right after the contentType, as in ...contentType("application/JSON").given().log().all().get("api/v2/some/endpoint")... – emery Jun 15 '21 at 19:25
2

RestAssured stores all the pieces of the URL it will construct as static variables.

System.out.println(RestAssured.baseURI + ":" + RestAssured.port + RestAssured.basePath + EndPoint.GET_ENDPOINT);

I don't know of a method that will combine them already, though I think it would be a reasonable feature request for a static method, or possibly on RequestSpecification.

Adam
  • 2,214
  • 1
  • 15
  • 26
  • 3
    While you may have solved this user's problem, code-only answers are not very helpful to users who come to this question in the future. Please edit your answer to explain why your code solves the original problem. – Joe C Feb 03 '17 at 22:03