简体   繁体   English

使用Rest Assured Get类型返回400状态代码的测试REST API

[英]Test REST API using Rest Assured Get type returning 400 status code

I'm able to test my REST API through postman client and its giving me the expected response. 我可以通过邮递员客户端测试REST API,并为其提供预期的响应。 But, when I try to test through junit, its giving 400 status code 但是,当我尝试通过junit进行测试时,它会给出400状态代码

Content type is application/json as per the payload 根据有效负载,内容类型为application / json

final static String ROOT_URI = "http://localhost:7000/employees";

@Test
public void simple_get_test() {
    Response response = get(ROOT_URI + "/list?emp=100");
}

Am I missing anything 我错过了什么吗

Try setting the port using RestAssured.port = 7000 and remove it from the URI. 尝试使用RestAssured.port = 7000设置端口,并将其从URI中删除。 It would be usefull if you post the response message aside from the code. 如果您在代码之外还发布了响应消息,则将很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM