【问题标题】:HttpResponseException: Bad Request occurs while implementing call inbound using vonage SDKHttpResponseException:使用 vonage SDK 实现呼叫入站时发生错误请求
【发布时间】:2021-01-27 12:26:39
【问题描述】:

我正在尝试在我的 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"
        }
      ]}'

【问题讨论】:

  • 有同样的问题。有什么关于问题的更新吗?
  • 这是由于 io.jsonwebtoken 的旧版本而发生的,如果您仍然遇到相同的异常,请参阅此问题的 pom.xml stackoverflow.com/questions/66221676/…

标签: java spring-mvc vonage


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2021-05-19
    • 2020-11-21
    • 2021-01-21
    • 2019-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    相关资源
    最近更新 更多