rest-assured - 如何在别名标头中传递电子邮件并获得特定响应?
问题描述
*新手放心
问题:
如何在别名标头中传递电子邮件( GET 端点所需的用户电子邮件)并从响应中获取会话 ID 和用户名 ID?
详细信息:[GET] 用户/登录端点需要用户电子邮件和 api 密钥。
卷曲:
curl -X GET "https://SomeWebSite.com/apiservice/users/signin?challengeMethod=EMAIL" -H "accept: application/json" -H "alias: usersignin@EXAMPLE.com" -H "X-API-KEY: d5a1d56d51d651d651d51d651d6d6d1"
回复:
{
"session": "ID inside of here",
"challengename": "CUSTOM_CHALLENGE",
"challengeSentTo": "usersignin@EXAMPLE.com",
"username": "5d654d6d65dd64d66adsb6a4"
}
我的代码:
public class AuthResponseTest {
public static final String baseUri = "https://qa-mobile-app-auth-ext.clearcollateral.com/";
public static final String basePath = "/apiservice/users ";
public String[] getSignIn() {
return RestAssured
.with()
.log().all()
.header("X-API-KEY", "API KEY IN HERE")
.header("alias", "email here")
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.baseUri(baseUri)
.basePath(basePath)
.when()
.post("/users/signin")
.then()
.log().all()
.statusCode(200)
.extract().as(String[].class);
}
@Test
public void testSignIn() {
String[] authsignin = getSignIn();
System.out.println(authsignin);
}
}
解决方案
尝试;
.header("alias", "usersignin@EXAMPLE.com")
推荐阅读
- python - 我在给定的图像中找不到此问题的 Oython 代码?
- css - 如何将流体文本大小公式基于 rem 值?
- firebase - 如何让 Firebase.dart 中的 updateProfile 工作?
- c - 如何使用星星作为框架和内部的破折号创建一个框架框?
- airflow - 气流任务调度独特的子任务
- javascript - .join() 函数在 map 函数中无法正常工作
- mysql - 有没有更好的方法来按部门获得最高(薪水)并确保只有你获得平均(薪水)> 50,000 的部门?
- kubernetes - 运行 `linkerd upgrade --from-manifests` 时没有类型的“APIService”注册错误
- list - 如何订购firebase的文件?
- c# - 如何将子项从 ListBox 添加到 ListView?