Skip to content

Language field in Verify API requests serialized incorrectly #213

@ravi-signal

Description

@ravi-signal

When I attempt to make a verify request like so:

VerifyRequest request = new VerifyRequest(recipient);
request.setType(VerifyType.TTS);
request.setLanguage(Language.DE_DE);
request.setOriginator(originator);

client.sendVerifyToken(request);

I get back a 422 with

Language must be one of: cy-gb, da-dk, de-de, el-gr, en-au, en-gb, en-in, en-us, es-es, es-mx, es-us, fr-ca, fr-fr, id-id, is-is, it-it, ja-jp, ko-kr, ms-my, nb-no, nl-nl, pl-pl, pt-br, pt-pt, ro-ro, ru-ru, sv-se, ta-in, th-th, tr-tr, vi-vn, zh-cn, zh-hk.

The serialized json request that ends up getting sent to the server is:

{
  "recipient": "redacted",
  "originator": "redacted",
  "type": "tts",
  "datacoding": "DataCoding{value=plain}",
  "language": "DE_DE"
}

It looks like the ObjectMapper being used is using default enum serialization. The Language enum does have correctly cased toString.

One way to fix this might be to enable toString serialization for enums in the ObjectMapper

mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);

but this may have other effects.

Two other notes:

  • the code tag for RU_RU is ru_ru but the API docs indicate it should be ru-ru
  • I only see this problem for tts, for sms verify it seems like the server completely ignores the language tag, unsure if that's a separate (upstream) issue.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions