0

我是 Zapi(Zephyr API)的新手。我正在尝试评估 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 中的任何测试用例。

谢谢。

4

1 回答 1

0

您需要使用 base64 编码的授权标头发送请求,如下所示:

授权标头使用 base64 编码的用户名和密码字符串

headers = {“授权”:“基本”+ b64encode(用户名+“:”+密码),“内容类型”:“应用程序/json”}

于 2015-06-03T14:31:14.207 回答