title: Grails RestBuilder simple POST example
body: <p>I'm trying to do an OAuth2 user-credentials post to an OAuth2 service using the Grails RestBuilder plugin.</p>
  
  <p>If I try to specify the post body as a map, I get an error about no message converters for LinkedHashMap.</p>
  
  <p>If I try to specify the body as a String, the post goes through, but none of the variables are posted to the server action.</p>
  
  <p>Here's the post:</p>
  
  <pre><code>RestBuilder rest = new RestBuilder()
  def resp = rest.post("http://${hostname}/oauth/token") {
      auth(clientId, clientSecret)
      accept("application/json")
      contentType("application/x-www-form-urlencoded")
  
      // This results in a message converter error because it doesn't know how
      // to convert a LinkedHashmap
      // ["grant_type": "password", "username": username, "password": password]
  
      // This sends the request, but username and password are null on the host
      body = ("grant_type=password&amp;username=${username}&amp;password=${password}" as String)
  }
  def json = resp.json
  </code></pre>
  
  <p>I've also tried setting the urlVariables in the post() method call, but the username/password are still null.</p>
  
  <p>This is a very simple post, but I can't seem to get it to work. Any advice would be greatly appreciated.</p>