【问题标题】:com.algorithmia.APIException: 308 unexpected API responsecom.algorithmia.APIException:308 意外的 API 响应
【发布时间】:2019-11-12 07:02:35
【问题描述】:

我正在使用 algorithmia,它是 Internet 上经过训练的 ML 函数的存储库。几周前,出现了一个问题,从那时起,就无法弄清楚发生了什么。我正在执行这段代码,可以在他们的官方网站上找到。

import com.algorithmia.Algorithmia;
import com.algorithmia.AlgorithmiaClient;
import com.algorithmia.algo.AlgoResponse;
import com.algorithmia.algo.Algorithm;

public class Main {

    public static void main(String[] args) throws Exception {
        String input = "A purely peer-to-peer...";
        AlgorithmiaClient client = Algorithmia.client("api_key");
        Algorithm algo = client.algo("nlp/Summarizer/0.1.8");
        algo.setTimeout(300L, java.util.concurrent.TimeUnit.SECONDS); //optional
        AlgoResponse result = algo.pipe(input);
        System.out.println(result.asJsonString());
    }

}

但是这段代码引发了以下异常:

Exception in thread "main" com.algorithmia.APIException: 308 unexpected API response: 
    at com.algorithmia.algo.Algorithm.pipeRequest(Algorithm.java:145)
    at com.algorithmia.algo.Algorithm.pipe(Algorithm.java:96)
    at Main.main(Main.java:13)

我想帮忙

  1. 创建一个 Maven 项目
  2. 添加这个 Maven 依赖项
<dependency>
  <groupId>com.algorithmia</groupId>
  <artifactId>algorithmia-client</artifactId>
  <version>[,1.1.0)</version>
</dependency>
  1. 粘贴上面显示的代码

进一步的观察和猜测

  • 发出 cURL 请求一切正常
  • 使用 Python 效果很好
  • 可能和HttpClient有关
  • Java 代码将与Charles 之类的代理一起使用
  • 参考 GitHub 上的opened issue

【问题讨论】:

    标签: java http httpclient http-status-code-308 algorithmia


    【解决方案1】:

    鉴于当前日期为 2019 年 7 月 2 日,他们发布了修复此类错误的版本 1.0.16

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-23
      • 1970-01-01
      • 2020-07-10
      • 2020-03-18
      • 1970-01-01
      • 2019-05-08
      • 2019-01-26
      相关资源
      最近更新 更多