如何解决线程“ AWT-EventQueue-0”中的异常java.lang.AssertionError:1个期望失败预期状态码为<200>,但为<401>
我正在尝试使用JIRA API在JIRA中查找重复的条目 该请求在邮递员中运行良好
但是当在intellij中执行相同的代码时,将引发错误,例如“线程“ AWT-EventQueue-0中的异常” java.lang.AssertionError:1期望失败。 预期状态码为,但为。”
粘贴代码的前半部分:
for (i = 1; i < getrowCount; i++) {
System.out.println("entered inside for loop");
System.out.println("Data captured finished");
//logic 1
RestAssured.baseURI = "example.com"; //adding dummy value due to confidential
SessionFilter sessionId = new SessionFilter();
String sessionResponse = given()
.header("Content-Type","application/json")
.body(Payload.UsrPwd(userName,password))
.filter(sessionId)
.when()
.post(resource.postsession_connection()).then().extract().response().asString();
System.out.println("Login finished");
//logic 2
Response duplicateResponse2 = given()
.filter(sessionId)
.when()
.get("example.com/rest/api/2/search?jql=text~xyz&startAt=0&maxResults=10&fields=Key")
.then()
.assertThat().statusCode(200).extract().response();
System.out.println("Duplicate request finished");
int statusCode = duplicateResponse2.getStatusCode();
System.out.println(statusCode);
JsonPath json = reusablemethods.jsonData(duplicateResponse2);
int duplicateTotalCount=json.get("total");
System.out.println(duplicateTotalCount);
//logic 3
if(duplicateTotalCount == 0)
{
execute code 1
}else
{execute code 2
} ```
Issue observed is 401 which is unauthorised
that means my sessionId is not passing to logic 2
Please help to me resolve this
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。