此代码给出超时错误,而服务在 postman/soapUI 中给出响应
我正在尝试自动化其余服务。该服务工作正常soapUI,但在restAssured 中自动化时出现超时错误。
import org.testng.annotations.Test;
import static io.restassured.RestAssured.given;
import io.restassured.RestAssured;
import io.restassured.response.Response;
public class AddUsers {
@Test
public void addUsers()
{
RestAssured.baseURI = "http://reqres.in";
given().header("Content-Type","application/json").body("{\r\n" +
" \"name\": \"Mallik\",\r\n" +
" \"job\": \"TestLead\"\r\n" +
"}").when().post("/api/users");
}
}
最佳答案
您需要使用 https。我得到了正确的输出
RestAssured.baseURI = "https://reqres.in";
Response resp = given().header("Content-Type", "application/json")
.body("{\n" + " \"name\": \"Mallik\",\n" + " \"job\": \"leader\"\n" + "}").when()
.post("/api/users");
System.out.println(resp.getStatusCode());
System.out.println(resp.asString());
关于java - RestAssured 中出现超时错误,而服务在 postman/soapUI 中给出响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58343693/