0

I have exactly the same issue as here: Jira user creation via REST results in 401 - This resource requires WebSudo. However, in my case, I want to connect with Java Http Client.

I've examined documentation and I've tried to:

  1. Put credentials in header

    {
        final String encoding = Base64.getEncoder().encodeToString((SERVICE_DESK_ADMIN + ":" + SERVICE_DESK_ADMIN_KEY).getBytes("UTF-8"));
        httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + encoding);
    }
    
  2. Try to implement preemptive authorization described here: HttpClient Basic Authentication

In both cases, I got the same response from server:

{
  "message" : "This resource requires WebSudo.",
  "status-code" : 401
}

In the preemptive case, I've spotted in log something like this:

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

My questions are:

  1. From the log, is the last line indicates that my configuration is not working?
  2. Does anybody have success in adding a user to the service desk via rest API with the usage of HTTP client?
PastorPL
  • 968
  • 3
  • 17
  • 36

1 Answers1

0

Here is the answer to my question:

  • HTTP Client has nothing to do with my problem
  • There are 2 possible solutions to create a user in JIRA with HTTP Client:
    1. Veeeery ugly - I 've noticed that first Http post to create user, returns cookies. Now, when getting these cookies and put them to next Http post and change login to email, will cause working (user will be created successfully). However, as I said, it's ugly and completely against the REST idea, since REST should be stateless.
    2. Disable WebSudo - Disable WEBSUDO in Jira. Small warning, to get this working you have to restart jira.

I pick the second solution and now it's working like a charm.

PastorPL
  • 968
  • 3
  • 17
  • 36