使用RestAssured从JIRA获取JSESSIONID会导致未知主机错误

问题描述 投票:1回答:1

我使用RestAssured编写了一个脚本来连接Jira并获取Session ID。以下是我的代码。

public void getJIRACookieTest(){        
    System.setProperty("https.proxyHost", "Host");
    System.setProperty("https.proxyPort", "PortNo");
    System.setProperty("https.proxyUserName","UserName");
    System.setProperty("https.proxyPassword","Password");       
    Response res = given().header("Content-Type","application/json").
    when().
    body("{\"username\":\"test\",\"password\":\"test\"}").
    post("https://jira_url/rest/auth/1/session").
    then().extract().response();
    System.out.println(res.prettyPrint().toString());
}

这里收到未知的主机错误消息。

然后我尝试Postman和它完美的工作正常。我刚刚在邮递员中选择了没有身份验证,Content-Type作为applicatio / json和body用户详细信息{\"username\":\"test\",\"password\":\"test\"}。当我尝试使用RestAssured时,不确定为什么会遇到未知的主机。

非常感谢您的帮助。

谢谢,Narendra

jira rest-assured
1个回答
0
投票

根据您的评论,我收集到您使用Postman与代理连接,这是有效的。

无论如何,您正在RestAssured测试中设置HTTPS代理:

System.setProperty("https.proxyHost", "Host");
System.setProperty("https.proxyPort", "PortNo");
System.setProperty("https.proxyUserName","UserName");
System.setProperty("https.proxyPassword","Password"); 

从测试中删除这些行后你应该没问题。

© www.soinside.com 2019 - 2024. All rights reserved.