Cannot retrieve messages for given conversation : VonageResponseParseException!
jerome25000 opened this issue · 3 comments
Hello, I am using the latest java SDK (8.9.0)
Create a conversation with 2 members. : ok
Add simple text message for the 2 members : ok
Try to get all conversation : KO
Following java code :
public void listMessages(ConversationsClient client, String roomId) {
ListEventsRequest request = ListEventsRequest.builder().eventType(EventType.MESSAGE).build();
ListEventsResponse response = client.listEvents(roomId, request);
Stacktrace
Exception in thread "main" com.vonage.client.VonageResponseParseException: Failed to produce ListEventsResponse from JSON.
at com.vonage.client.Jsonable.updateFromJson(Jsonable.java:82)
at com.vonage.client.Jsonable.fromJson(Jsonable.java:128)
at com.vonage.client.DynamicEndpoint.parseResponseSuccess(DynamicEndpoint.java:308)
at com.vonage.client.DynamicEndpoint.parseResponse(DynamicEndpoint.java:244)
at com.vonage.client.AbstractMethod.execute(AbstractMethod.java:82)
at com.vonage.client.conversations.ConversationsClient.listEvents(ConversationsClient.java:363)
at com.vonage.client.conversations.ConversationsClient.listEvents(ConversationsClient.java:348)
at org.example.VonageConversationManager.listMessages(VonageConversationManager.java:74)
at org.example.VonageConversationManager.main(VonageConversationManager.java:105)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.util.ArrayList<com.vonage.client.conversations.Event>
from Object value (token JsonToken.START_OBJECT
)
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION
disabled); line: 1, column: 30] (through reference chain: com.vonage.client.conversations.ListEventsResponse["_embedded"])
The java response is not complient with the java
public final class ListEventsResponse extends HalPageResponse {
@JsonProperty("_embedded")
private List events;
ListEventsResponse() {
}
@JsonProperty("_embedded")
public List<Event> getEvents() {
return this.events;
}
}
Should have a intermediate object embeded (having a event property) like this :
public final class ListEventsResponse extends HalPageResponse {
@JsonProperty("_embedded")
Embedded embedded;
ListEventsResponse() {}
@JsonProperty("_embedded")
public List<Event> getEvents() {
return this.embedded.getEvents();
}
}
public class Embedded {
Embedded() {}
@JsonProperty("events")
private List<Event> events;
@JsonProperty("events")
public List<Event> getEvents() {
return this.events;
}
}
Hello,
I encountered the same issue with the latest Java SDK (8.9.0). The exception occurs when trying to list all conversation messages.
For context, I also experienced the same problem with SDK version 8.6.0.
Thank you.
Thanks for raising this, will have this fixed in the next patch release.
Fixed in v8.9.1, however please note many read-only events in the API are not currently supported, so you will have to query them manually through the getBody()
method of GenericEvent
, which provides a Map<String, ?>
rather than native data structures. Support for events will be expanded in future releases.