0

测试轨道 API 绑定 - 无法识别的响应代码 (308)

我是 test rail 的新手,我开始实施自动化基础设施,将自动化测试结果同步到 Test Rail 服务器。我正在使用Java,这是代码片段......

package com.util.testrail;

import com.util.log.ColorLog;
import com.util.testrail.APIClient;
import com.util.testrail.APIException;
import java.util.Map;
import java.util.HashMap;
import org.json.simple.JSONObject;

public class Program
{
    public static void main(String[] args) throws Exception
    {
        APIClient client = new APIClient("http://ect.testrail.io/");
        client.setUser("asih@evercompliant.com");
        client.setPassword("asi1234$");

        Map data = new HashMap();
        data.put("status_id", new Integer(1));
        data.put("comment", "This test worked fine!");
        JSONObject r = (JSONObject) client.sendPost("add_result_for_case/1/1", 
        data);

        JSONObject c = (JSONObject) client.sendGet("get_case/1");
        System.out.println(c.get("title"));


    }
}

我得到的例外:

Exception in thread "main" com.util.testrail.APIException: TestRail API return HTTP 308 (No additional error message received)
        at com.util.testrail.APIClient.sendRequest(APIClient.java:159)
        at com.util.testrail.APIClient.sendPost(APIClient.java:115)
        at com.util.testrail.Program.main(Program.java:21)
    Disconnected from the target VM, address: '127.0.0.1:51632', transport: 'socket'
4

1 回答 1

0

问题实际上是您尝试使用 http:// 而不是 https://,从而导致重定向。确保使用正确的 HTTPS 地址:https ://seleniumautomation.testrail.net/

于 2018-06-06T18:43:58.223 回答