当前位置: 首页 > 知识库问答 >
问题:

Zapi API:如何使用Zapi API登录Zephyr以获取详细信息或更新任何测试用例

闻人鸿飞
2023-03-14

我是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中的任何测试用例。

谢谢。

共有1个答案

冉高寒
2023-03-14

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

Headers={"授权":"基本"b64encode(用户名":"密码),"Content-Type":"应用程序/json"}

 类似资料: