gpt4 book ai didi

java - HttpResponseException : Bad Request occurs while implementing call inbound using vonage SDK

转载 作者:行者123 更新时间:2023-12-05 06:52:38 40 4
gpt4 key购买 nike

我正在尝试在我的 spring MVC 项目中使用 nexmo api 实现调用功能,但我不断收到以下异常

com.vonage.client.VonageResponseParseException: Unable to parse response.
at com.vonage.client.AbstractMethod.execute(AbstractMethod.java:105) ~[client-6.1.0.jar:6.1.0]
at com.vonage.client.voice.CallsEndpoint.post(CallsEndpoint.java:57) ~[client-6.1.0.jar:6.1.0]
at com.vonage.client.voice.VoiceClient.createCall(VoiceClient.java:61) ~[client-6.1.0.jar:6.1.0]
.............................
Caused by: org.apache.http.client.HttpResponseException: Bad Request
at org.apache.http.impl.client.AbstractResponseHandler.handleResponse(AbstractResponseHandler.java:69) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:65) ~[httpclient-4.5.1.jar:4.5.1]
at com.vonage.client.voice.CreateCallMethod.parseResponse(CreateCallMethod.java:57) ~[client-6.1.0.jar:6.1.0]
at com.vonage.client.voice.CreateCallMethod.parseResponse(CreateCallMethod.java:32) ~[client-6.1.0.jar:6.1.0]
at com.vonage.client.AbstractMethod.execute(AbstractMethod.java:102) ~[client-6.1.0.jar:6.1.0]
... 51 more

下面是我的代码逻辑

VonageClient client = VonageClient.builder().applicationId(APPLICATION_ID).privateKeyContents(PRIVATE_KEY).build();
Ncco ncco = new Ncco(TalkAction.builder("message").build());
Call call = new Call(TO_NUMBER, FROM_NUMBER, ncco);
CallEvent result = client.getVoiceClient().createCall(call);

尽管入站调用可以使用下面的 curl 命令工作

curl -X POST https://api.nexmo.com/v1/calls\
-H "Authorization: Bearer "$JWT\
-H "Content-Type: application/json"\
-d '{"to":[{"type": "phone","number": "TO_NUMBER"}],
"from": {"type": "phone","number": "FROM_NUMBER"},
"ncco": [
{
"action": "talk",
"text": "This is a text to speech call from Vonage"
}
]}'

最佳答案

此处提供的代码似乎在 5.6.0 版本的 nexmo 客户端上运行良好 - 我会确保您一直是最新的。

该错误表明传递给 nexmo API 的内容是错误的,因此如果升级后这仍然是一个问题,可能值得打开一些日志记录 here's an example of how to turn on logging .这将使您能够准确地看到它传递的是什么,也许还能找出问题所在。

关于java - HttpResponseException : Bad Request occurs while implementing call inbound using vonage SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65919153/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com