title: Grails: POST method for JIRA basic auth - Unsupported Media Type
body: <p>I am developing an application that extracts data from a JIRA database. I am using RESTClient API to do basic authentication using <strong>post</strong> method.</p>
  
  <p>Full code (redacted):</p>
  
  <pre><code>class IssuesController {
  
      def xyz = this.encodeAuth("username", "password")
      def index() {
  
          def login = new RESTClient ('http://my-jira/rest/auth/1/')
          def response = login.post(
              path : 'session',
              headers : ['Authorization' : 'Basic ' + xyz + '=='])
  
          render response.data.toString()
  
      }
      public String encodeAuth(username, password) {
          def authC = username + ':' + password
          def bytes = authC.bytes
          return bytes.encodeBase64().toString();
      }
  </code></pre>
  
  <p>I am getting an <code>HTTPResponseException</code> with a message <code>Unsupported Media Type</code>. If I use <strong>get</strong> method instead, the authentication works just fine. (But it doesn't start a session, so no use). I even tried changing the headers, <code>headers : ['Content-Type' : 'application/json', 'Accept' : 'application/json']</code>.</p>
  
  <p>Used FireBug to analyze the network headers, the <code>Content-Type</code> and <code>Accept</code> headers still didn't change.</p>
  
  <pre><code>Response Headers
  
  HTTP/1.1 500 Internal Server Error
  
  Content-Type: text/html;charset=UTF-8
  
  Content-Language: en-US
  
  Connection: close
  
  
  Request Headers
  
  GET /GTPortal/issues/index HTTP/1.1
  
  Host: localhost:8099
  
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0
  
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  
  Accept-Language: en-US,en;q=0.5
  
  Accept-Encoding: gzip, deflate
  </code></pre>
  
  <p>Any help why the message Unsupported Media Type when using POST!?</p>