我正在尝试使用以下代码进行 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"} "
这只发生在我尝试使用更大的字符串进行调用时,当应用更小的字符串时,我得到了我需要的结果。