In most of the organisations we have proxies and while using restassured we face “java.net.ConnectException: Connection timed out” or “java.net.ConnectException: Connection refused” error as proxy does not allows the traffic. To resolve same we need to set the proxy settings before making the call. To do the same there are two methods – either use System.setProperty or use io.restassured.specification . While using System.setProprty again there are two ways. One is just use system proxy System.setProperty (“java.net.useSystemProxies”, “true”); Or set all properties manually as below // The hostname, or address, of the proxy server used by the HTTP protocol handler. System.setProperty(“http.proxyHost”, “myproxy.domain.com”); // The port number of the proxy server used by the HTTP protocol handler. System.setProperty(“http.proxyPort”, “8080”); // The hostname, or address, of the proxy server used by the HTTPS protocol handler. System.setProperty(“https.proxyHost”, “myproxy.domain.com”); // The port number of the proxy server used by the HTTPS protocol handler. System.setProperty(“https.proxyPort”, “443”);… Read more“Using restassured to call API behind proxy”
Tag: restassured
The import io.restassured.RestAssured cannot be resolved
While consuming restassured maven dependencies it has been observed that even after downloading the dependencies eclipse is not able to resolve io.restassured package. Maven repository (https://mvnrepository.com/artifact/io.rest-assured/rest-assured) has the scope set to test in the dependency tag. This limits your code from accessing that dependency’s classes within your source code. That is, you can access those classes only within your test sources (ex: ${project.dir}/src/test/java/, ${project.dir}/test/. Mostly that is not the intended use case, so just remove the scope attribute. <!– https://mvnrepository.com/artifact/io.rest-assured/rest-assured –> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>4.3.2</version> <!– <scope>test</scope> –> </dependency>