title: JIRA Rest API change issue status --> 401 error
body: <p>I'm trying to change the status of a Jira Issue with the Rest API, as described here: <a href="https://docs.atlassian.com/jira/REST/6.3-m01-1/" rel="nofollow">https://docs.atlassian.com/jira/REST/6.3-m01-1/</a></p>
  
  <p>I post to the URL </p>
  
  <pre><code>XXXXXX/rest/api/latest/issue/Project-Key/transitions?expand=transitions.fields
  </code></pre>
  
  <p>However, it doesn't work :(, I get a an 401 error (unauthorized), even though i authenticate like described in the atlassian documentation. (user used to authenticate has the permission to change the status)</p>
  
  <pre><code>client.addFilter(new HTTPBasicAuthFilter("username", "password"));
  WebResource webResource = client.resource(getDestination());
  </code></pre>
  
  <p>Though, get request works fine an returns:</p>
  
  <pre><code> {
      "expand": "transitions",
      "transitions": [{
          "id": "961",
          "name": "Deploybar",
          "to": {
              "self": "https://issues.xxxxxxxxx.local/jira/rest/api/2/status/10009",
              "description": "",
              "iconUrl": "https://issues.xxxxxxxxx.local/jira/images/icons/statuses/generic.png",
              "name": "Deploybar",
              "id": "10009",
              "statusCategory": {
                  "self": "https://issues.xxxxxxxxx.local/jira/rest/api/2/statuscategory/4",
                  "id": 4,
                  "key": "indeterminate",
                  "colorName": "yellow",
                  "name": "In Arbeit"
              }
          },
          "fields": {
              "assignee": {
                  "required": false,
                  "schema": {
                      "type": "user",
                      "system": "assignee"
                  },
                  "name": "Bearbeiter",
                  "autoCompleteUrl": "https://issues.xxxxxxxxx.local/jira/rest/api/latest/user/assignable/search?issueKey=RCE-98&amp;username=",
                  "operations": ["set"]
              }
          }
      }
  } 
  </code></pre>
  
  <p>Here is how I try to post:</p>
  
  <pre><code>final WebResource webResTransition = jiraTransition.response();
  final ClientResponse crTest = webResTransition.accept("application/json").type("application/json").post(ClientResponse.class, {"transition": {"id": "961"}});
  </code></pre>
  
  <p><strong>My try with Jira Rest Client:</strong> </p>
  
  <pre><code>final JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
      final URI jiraServerUri = new URI("https://issues.teamspace.local/rest/api/latest");
      final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "username", "password");
      final NullProgressMonitor pm = new NullProgressMonitor();
      final Issue issue = restClient.getIssueClient().getIssue("Issue-Key", pm);
  </code></pre>
  
  <p><strong>Error Message:</strong></p>
  
  <pre><code>com.atlassian.jira.rest.client.RestClientException: com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:75)
      at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.getAndParse(AbstractJerseyRestClient.java:80)
      at com.atlassian.jira.rest.client.internal.jersey.JerseyIssueRestClient.getIssue(JerseyIssueRestClient.java:113)
      at at.racon_linz.jenkins.stash_plugin.test.JiraTest.testClient(JiraTest.java:51)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at junit.framework.TestCase.runTest(TestCase.java:176)
      at junit.framework.TestCase.runBare(TestCase.java:141)
      at junit.framework.TestResult$1.protect(TestResult.java:122)
      at junit.framework.TestResult.runProtected(TestResult.java:142)
      at junit.framework.TestResult.run(TestResult.java:125)
      at junit.framework.TestCase.run(TestCase.java:129)
      at junit.framework.TestSuite.runTest(TestSuite.java:255)
      at junit.framework.TestSuite.run(TestSuite.java:250)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at com.sun.jersey.client.apache.DefaultApacheHttpMethodExecutor.executeMethod(DefaultApacheHttpMethodExecutor.java:213)
      at com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHandler.java:175)
      at com.sun.jersey.api.client.Client.handle(Client.java:648)
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670)
      at com.sun.jersey.api.client.WebResource.get(WebResource.java:191)
      at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient$1.call(AbstractJerseyRestClient.java:84)
      at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:54)
      ... 22 more
  Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1747)
      at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241)
      at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235)
      at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1209)
      at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:135)
      at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593)
      at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:943)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:654)
      at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:100)
      at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
      at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
      at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828)
      at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.flushRequestOutputStream(MultiThreadedHttpConnectionManager.java:1565)
      at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116)
      at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
      at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
      at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
      at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
      at com.sun.jersey.client.apache.DefaultApacheHttpMethodExecutor.executeMethod(DefaultApacheHttpMethodExecutor.java:210)
      ... 28 more
  Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:323)
      at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:217)
      at sun.security.validator.Validator.validate(Validator.java:218)
      at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
      at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
      at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
      at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1188)
      ... 45 more
  Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
      at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
      at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:318)
      ... 51 more
  </code></pre>
  
  <p><strong>Error without HTTPS</strong></p>
  
  <pre><code>com.atlassian.jira.rest.client.RestClientException: com.sun.jersey.api.client.UniformInterfaceException: Client response status: 302
  at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:70)
  at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.getAndParse(AbstractJerseyRestClient.java:80)
  at com.atlassian.jira.rest.client.internal.jersey.JerseyIssueRestClient.getIssue(JerseyIssueRestClient.java:113)
  at at.racon_linz.jenkins.stash_plugin.test.JiraTest.testClient(JiraTest.java:52)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at junit.framework.TestCase.runTest(TestCase.java:176)
  at junit.framework.TestCase.runBare(TestCase.java:141)
  at junit.framework.TestResult$1.protect(TestResult.java:122)
  at junit.framework.TestResult.runProtected(TestResult.java:142)
  at junit.framework.TestResult.run(TestResult.java:125)
  at junit.framework.TestCase.run(TestCase.java:129)
  at junit.framework.TestSuite.runTest(TestSuite.java:255)
  at junit.framework.TestSuite.run(TestSuite.java:250)
  at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>
  
  <p>Caused by: com.sun.jersey.api.client.UniformInterfaceException: Client response status: 302
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:676)
      at com.sun.jersey.api.client.WebResource.get(WebResource.java:191)
      at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient$1.call(AbstractJerseyRestClient.java:84)
      at com.atlassian.jira.rest.client.internal.jersey.AbstractJerseyRestClient.invoke(AbstractJerseyRestClient.java:54)
      ... 22 more</p>
  
  <p>I tried everything I found about this topic, but nothing was working :(</p>