0

我正在尝试使用以下代码进行 api 调用

'''

    MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
    //this is where the error is beign thrown
    RequestBody body = RequestBody.create(mediaType, "text="+this.body);
    Request request = new Request.Builder()
            .url("https://text-sentiment.p.rapidapi.com/analyze")
            .post(body)
            .addHeader("content-type", "application/x-www-form-urlencoded")
            .addHeader("x-rapidapi-key", "API Key")
            .addHeader("x-rapidapi-host", "Host")
            .build();
    client.newCall(request).enqueue(new Callback() {

'''

但是当我运行它时,我得到 "{"status":100,"errormsg":"Failed to parse text in form param"} "

这只发生在我尝试使用更大的字符串进行调用时,当应用更小的字符串时,我得到了我需要的结果。

4

1 回答 1

-1

有趣的!我期待您在 RapidAPI Hub 上使用文本情感分析方法API。即使对于大字符串,它对我来说也很好。通常 100 状态码表示客户端避免在服务器基于请求标头打算拒绝请求时通过网络发送大量数据。

它现在应该可以工作了。你可以再检查一下。您可以将您的查询发送给 RapidAPI 的支持团队,以防万一它仍然不适合您。

于 2021-08-23T18:39:22.747 回答