com.algorithmia.APIException:308 意外的 API 响应

Posted

技术标签:

【中文标题】com.algorithmia.APIException:308 意外的 API 响应【英文标题】:com.algorithmia.APIException: 308 unexpected API response 【发布时间】: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)

我想帮忙

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

进一步的观察和猜测

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

【问题讨论】:

【参考方案1】:

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

【讨论】:

以上是关于com.algorithmia.APIException:308 意外的 API 响应的主要内容,如果未能解决你的问题,请参考以下文章