title: Grails extract body data from the request
body: <p>I have some controller (<code>ExampleController</code>) that receives requests with <code>content-type</code> <code>application/x-www-form-urlencoded</code>.</p>
  
  <p>I need to send all the request data to a different URL using <code>POST</code> request. The data needs to be in the same order as received it.</p>
  
  <p>Problem is that the content does not match because <code>request.getParameterMap()</code> destroys the order of the data.
  In <code>ExampleController</code>:</p>
  
  <pre><code>def method(){ 
      String s = request.reader.text //this is empty, need a way to read this text
      Map&lt;String, String[]&gt; vars = request.getParameterMap() //it's not good for me   because the map is unordered map 
      //but it full of data
  
  }
  </code></pre>
  
  <p>which does not work.</p>
  
  <p>I need something like:</p>
  
  <pre><code>byte[] data = request.getRequestData()
  wr.write(data)
  </code></pre>
  
  <p>btw i've tried:</p>
  
  <pre><code>InputStream = request.getInputStream()
  byte [] bytes = inputStream.getBytes()
  </code></pre>
  
  <p>I've also tried</p>
  
  <pre><code>String s = request.reader.text
  </code></pre>
  
  <p>but the string is empty.
  I think the main problem is that grails mechanism reads the input stream before the controller even starts and place the data in the parameters hashMap. is there a way to undo it?</p>
  
  <p>Any help will be greatly appreciated</p>