Getting the following error while updating phone
lang.IllegalArgumentException: cannot write xcontent for unknown value of type class com.company.Phone]
http://localhost/users/vfu1i3cB1FVgFWdzuLfj/update
{
"nu": "9823456344",
"cc": "91"
}
Converters look like this
@WritingConverter
public static class ToMap implements Converter<Phone, Map<String, Object>> {
@Override
public Map<String, Object> convert(Phone source) {
LinkedHashMap<String, Object> target = new LinkedHashMap<>(8);
target.put(NAME, source.name);
target.put(NUMBER, source.number);
target.put(COUNTRY_CODE, source.countryCode);
return target;
}
}
@ReadingConverter
public static class ToPhone implements Converter<Map<String, Object>, Phone> {
@Override
public Phone convert(Map<String, Object> source) {
Phone phone = new Phone();
phone.setName((String)source.get(NAME));
phone.setNumber((String)source.get(NUMBER));
phone.setCountryCode((String)source.get(COUNTRY_CODE));
return phone;
}
}