【问题标题】:twilio phoneNUmber pricing api throw exceptiontwilio phoneNUMer 定价 api 抛出异常
【发布时间】:2021-06-14 10:30:30
【问题描述】:

https://pricing.twilio.com/v1/PhoneNumbers/Countries/{countryCode}

API 正在获取国家/地区并给出类似的响应

预期响应 =>

{
    "url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries/US",
    "country": "United States",
    "price_unit": "USD",
    "phone_number_prices": [
        {
            "number_type": "local",
            "base_price": "1.00",
            "current_price": "1.00"
        },
        {
            "number_type": "toll free",
            "base_price": "2.00",
            "current_price": "2.00"
        }
    ],
    "iso_country": "US"
}

但我在获取国家/地区时遇到问题,它会给出异常

Country country= Country.fetcher(countryCode).fetch();

异常 =>

Unrecognized field "number_type" (class com.twilio.type.PhoneNumberPrice), not marked as ignorable (5 known properties: "basePrice", "type", "base_price", "currentPrice", "current_price"])
 at [Source: (org.apache.http.conn.EofSensorInputStream); line: 1, column: 212] (through reference chain: com.twilio.rest.pricing.v1.phonenumber.Country["phone_number_prices"]-
>java.util.ArrayList[0]->com.twilio.type.PhoneNumberPrice["number_type"])

如何解决这个问题

【问题讨论】:

  • 错误怎么看不清楚?无法识别的字段“number_type”(com.twilio.type.PhoneNumberPrice 类),未标记为可忽略(5 个已知属性:“basePrice”、“type”、“base_price”、“currentPrice”、“current_price”])它准确列出了什么您可以拥有的字段,而 number_type 不是其中之一。将 number_type 更改为类型。另外,为什么同时存在 currentPrice 和 current_price?
  • 私人最终双底价;私人最终双 currentPrice;私有最终类型类型;我的 PhoneNumberPrice 类中有三个属性
  • 您可能希望从阅读错误消息开始。
  • 认真:阅读错误信息:它详细地告诉您出了什么问题。在 json 中,您有 number_type 类型,而您的班级中没有。因此,将您的 json 从 number_type 更改为 type,或尝试将其解析为正确的类。

标签: java twilio


【解决方案1】:

这里是 Twilio 开发者宣传员。

您使用的是哪个版本的 Twilio Java 库?这看起来像an issue that was fixed back in March 2017

我建议您升级您正在使用的 Twilio Java 库的版本,如果这不能解决问题,请提出 an issue on the library repo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-04
    • 2011-05-30
    • 2013-01-02
    • 2018-06-19
    • 2013-05-24
    • 2015-04-15
    • 1970-01-01
    相关资源
    最近更新 更多