title: Using Luracast Restler -- passing POST vars as JSON in body
body: <p>Evaluating Lurasoft RESTler for a project and got stuck on their examples -- trying to pass JSON structure through the body of a post request...I've a working set-up with passing data via the URL but I wanted to get this post-via-body data figured out:</p>
  
  <p>So, I have a simple method for handling POST requests defined within the UserAccount class:</p>
  
  <pre><code>function post($_requestData = null) {
      if (is_null($_requestData)) {
          throw new RestException(HTTPCODE_NO_CONTENT, "requestData is null");
      }
      return(array('success' =&gt; array('code' =&gt; HTTPCODE_OK, 'msg' =&gt; $msg)));
  }
  </code></pre>
  
  <p>And I invoke with curl:</p>
  
  <pre><code>curl -X POST http://ll2api/userprofile -H "Content-Type: application/json" -d '{"email_pro" : "mshallop@nileguide.com"}'
  </code></pre>
  
  <p>I get returned, every time:</p>
  
  <pre><code>{
    "error": {
      "code": 204,
      "message": "No Content: requestData is null"
    }
  }
  </code></pre>
  
  <p>If I use the tool LuraCast recommends on their website to generate the REST request, RESTConsole v 4.0.2, I see where my data is being received when the payload is being defined using the "request parameters" section as shown in the request body:</p>
  
  <pre><code>Request Url: http://ll2api/userprofile
  Request Method: POST
  Status Code: 200
  Params: {
      "email_pro": "mshallop@gmail.com"
  }
  </code></pre>
  
  <p>Finally, from reading their example, I see where the input parameter "$requestData" is broken down as an associative array in their validate() method, treating the JSON input as an associative array...</p>
  
  <p>For completeness, here's the REQUEST headers:</p>
  
  <pre><code>Accept: application/json
  Accept-Language: en
  Content-Type: application/json
  Connection: keep-alive
  Origin: chrome-extension: //rest-console-id
  User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.904.0 Safari/535.7
  </code></pre>
  
  <p>So, tl;dr:  To avoid clogging-up the URL of the REST request, how do I pass JSON data via the body of a POST request to LuraCast RESTler and pick-up said variables within the method?</p>
  
  <p>reference site:  <a href="http://help.luracast.com/restler/examples/_006_crud/readme.html" rel="nofollow">http://help.luracast.com/restler/examples/_006_crud/readme.html</a></p>
  
  <p>Appreciate any help - this is my first run at REST so I suspect my issue is pbck/nub...</p>
  
  <p>thanks!</p>