У меня точно такая же проблема, как и здесь: Создание пользователя Jira с помощью REST приводит к 401 - Для этого ресурса требуется WebSudo . Однако в моем случае я хочу подключиться к Java Http Client.
Я изучил документацию и попытался:
Ввести учетные данные в header
{
final String encoding = Base64.getEncoder().encodeToString((SERVICE_DESK_ADMIN + ":" + SERVICE_DESK_ADMIN_KEY).getBytes("UTF-8"));
httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + encoding);
}
Попробуйте реализовать упреждающую авторизацию, описанную здесь: HttpClient Basi c Аутентификация
В обоих В случаях, когда я получал такой же ответ от сервера:
{
"message" : "This resource requires WebSudo.",
"status-code" : 401
}
В превентивном случае я заметил в журнале что-то вроде этого:
2020/03/03 16:41:45:774 CET [DEBUG] MainClientExec - Connection can be kept alive indefinitely
2020/03/03 16:41:45:774 CET [DEBUG] HttpAuthenticator - Authentication required
2020/03/03 16:41:45:774 CET [DEBUG] HttpAuthenticator - <here_is_address>:443 requested authentication
2020/03/03 16:41:45:774 CET [DEBUG] TargetAuthenticationStrategy - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, CredSSP, Digest, Basic]
2020/03/03 16:41:45:774 CET [DEBUG] TargetAuthenticationStrategy - Challenge for Negotiate authentication scheme not available
2020/03/03 16:41:45:774 CET [DEBUG] TargetAuthenticationStrategy - Challenge for Kerberos authentication scheme not available
2020/03/03 16:41:45:774 CET [DEBUG] TargetAuthenticationStrategy - Challenge for NTLM authentication scheme not available
2020/03/03 16:41:45:774 CET [DEBUG] TargetAuthenticationStrategy - Challenge for CredSSP authentication scheme not available
2020/03/03 16:41:45:774 CET [DEBUG] TargetAuthenticationStrategy - Challenge for Digest authentication scheme not available
2020/03/03 16:41:45:774 CET [DEBUG] TargetAuthenticationStrategy - Challenge for Basic authentication scheme not available
Мои вопросы:
- Из журнала последняя строка указывает, что моя конфигурация не работает?
- У кого-нибудь есть успехи в добавлении пользователя в службу поддержки через rest API с использованием HTTP-клиента?