问题描述
我正在尝试使用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 (将#修改为@)