Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot retrieve messages for given conversation : VonageResponseParseException! #536

Closed
jerome25000 opened this issue Jul 4, 2024 · 3 comments

Comments

@jerome25000
Copy link

jerome25000 commented Jul 4, 2024

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;
}

}

@jerome25000 jerome25000 changed the title Cannot retrieve message for conversation : errors ! Cannot retrieve messages for given conversation : VonageResponseParseException! Jul 4, 2024
@fgtamburrodeb
Copy link

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.

@SMadani
Copy link
Contributor

SMadani commented Jul 8, 2024

Thanks for raising this, will have this fixed in the next patch release.

@SMadani
Copy link
Contributor

SMadani commented Jul 9, 2024

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.

@SMadani SMadani closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants