我的网址如下所示
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,则可以正常运行而无需放心。我没弄错我要去哪里
答案 0 :(得分:0)
I could get it working with below code
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>