I also encountered the same error. Here I changed the code and it works for me. Error 401 is not an authorized error when we call any getConfigurationForm () without joining it.
multiUserChat.join(nickname, password); setConfig(multiUserChat);
private void setConfig(MultiUserChat multiUserChat) { try { Form form = multiUserChat.getConfigurationForm(); Form submitForm = form.createAnswerForm(); for (Iterator<FormField> fields = submitForm.getFields(); fields .hasNext();) { FormField field = (FormField) fields.next(); if (!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable() != null) { submitForm.setDefaultAnswer(field.getVariable()); } } submitForm.setAnswer("muc#roomconfig_publicroom", true); submitForm.setAnswer("muc#roomconfig_persistentroom", true); multiUserChat.sendConfigurationForm(submitForm); } catch (Exception e) { e.printStackTrace(); } }
And now I can successfully submit the form without any exceptions. Hope this works for you.
u_pendra
source share