带有 --data-binary 的 cURL 尝试使用放心抛出 500 错误进行自动化



I've cURL 如下

curl -H 'Host: api.staging.test.com' -H 'accept: application/json' -H 'content-type: application/json; charset=utf-8' -H 'user-agent: okhttp/3.10.0' --data-binary '{"emailId":"test@test.com","password":"test123"}' --compressed 'https://api.staging.test.com/user/develop-account/v1/session?storeId=100'

我正在尝试使用以下rest-assured自动化此操作

request = given().
log().all().
auth().basic("test@test.com", "test123").
header("Host", HOST_HEADER).
header("user-agent", USER_AGENT).
header("accept", ACCEPT).
header("content-type", CONTENT_TYPE);
response = request.when().
post("https://api.staging.test.com/user/develop-account/v1/session?storeId=100");
json = response.then().statusCode(200);

但是获得 500,登录工作正常,无需放心。我没有明白我错在哪里

我可以让它使用以下代码

Map<String, Object> params = new HashMap<>();
params.put("emailId", "test@test.com");
params.put("password", "test123");
request = given().
log().all().
header("Host", HOST_HEADER).
header("user-agent", USER_AGENT).
header("accept", ACCEPT).
header("content-type", CONTENT_TYPE).
contentType(JSON).
body(params);
response = request.when().
post(ENDPOINT_FOR_LOGIN);

json = response.then().statusCode(200);

import static io.restassured.http.ContentType.JSON;
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<scope>test</scope>
</dependency>

相关内容

  • 没有找到相关文章

最新更新