我刚接触Zapi(Zephyr )。我正在尝试为自动测试用例结果更新评估Zapi API。在尝试获取有关使用它的测试用例的详细信息时,我在控制台上收到“请登录”消息。我正在尝试从以下链接使用Zapi Rest API:http://docs.getzephyr.apiary.io/。
下面是我用来获取特定测试用例详细信息的代码:
Client client = ClientBuilder.newClient();
Response response = client.target("https://SERVER_NAME").path("/jira/browse/DEV-3121").request(MediaType.APPLICATION_JSON_TYPE).get();
System.out.println("status: " + response.getStatus());
System.out.println("headers: " + response.getHeaders());
System.out.println("body:" + response.readEntity(String.class));我在控制台上看到了下面的消息:
<fieldset class="hidden parameters">
<input type="hidden" title="loggedInUser" value="">
<input type="hidden" title="ajaxTimeout" value="The call to the JIRA server did not complete within the timeout period. We are unsure of the result of this operation.">
<input type="hidden" title="JiraVersion" value="6.2.7" />
<input type="hidden" title="ajaxUnauthorised" value="You are not authorized to perform this operation. Please log in.">
<fieldset/>请让我知道,我在这里遗漏了什么,否则有没有其他方法可以让我获取测试用例的详细信息,或者更新Jira-Zephyr中的任何测试用例。
谢谢。
发布于 2015-06-03 22:31:14
您需要发送带有base64编码的授权头的请求,如下所示:
授权头使用base64编码的用户名和密码字符串
headers = {"Authorization ":“Basic”+b64encode(用户名+“+密码),"Content-Type":”应用程序/json“}
https://stackoverflow.com/questions/30098986
复制相似问题