Hello everyone,
I'm trying to answer an inbound call using java SDK. I receive the inbound call event, a then try to answer using patchConversationParticipant, but it's not working. The parameters seems to be ok, because if I use another conversationId or participantId, I get an exception.
This is the code I'm using:
{
ConversationNotification eventBody = (ConversationNotification) event.getEventBody();
String conversationId = eventBody.getId();
//Getparticipants is below
ConversationNotificationParticipants participante = getParticipants(sUserId, eventBody.getParticipants());
String sParticipantId = participante.getId();
MediaParticipantRequest body = new MediaParticipantRequest();
body.setState(MediaParticipantRequest.StateEnum.CONNECTED);
try {
apiInstance.patchConversationParticipant(conversationId, sParticipantId, body);
} catch (ApiException aex) {
Print("[ApiException] " +aex.getMessage());
Print("[ApiException text] " + aex.toString());
}
}
////////////////// Get Participants
private ConversationNotificationParticipants getParticipantes (String id, List<ConversationNotificationParticipants> participantList){
if(participantList == null) {
Print("participantList null");
} else {
for(int i=0; i<participantList.size(); i++) {
Print(participantList.get(i).getUserId() + "," + id);
try{
if (participantList.get(i).getUserId() == null) {
Print("UserId null");
} else {
if (participantList.get(i).getUserId().equals(id)) {
try {
return participantList.get(i);
} catch (Exception ex) {
Print("[ERROR] " + ex.getMessage());
Print("[CAUSE] " + ex.getCause());
ex.printStackTrace();
}
}
}
} catch (Exception ex) {
Print("[ERROR] " + ex.getMessage());
Print("[CAUSE] " + ex.getCause());
ex.printStackTrace();
}
}
}
return null;
}
Any ideas on what the problem could be?
Regards,
Blas.