title: Sending POST/PUT via AJAX using casperjs
body: <p>Is it possible to 'POST' or 'PUT' a JSON object to an API with Casperjs?</p>
  
  <p>I can successfully do a GET call to my API. I just can't seem to get a POST/PUT to work.</p>
  
  <p>I am trying to send a JSON object to my website through the API I have setup.  I am using the newest version of Casperjs and am setting --web-security=no through the command line.  I read the documentation but have found no place to add header values to the AJAX call.  I see there is an "options" parameter but the following doesn't work.  I know the JSON and the URL are all correct because I have tried it with the chrome extension postman.  I just can't seem to figure out how to add headers.</p>
  
  <pre><code>try {
      return JSON.parse(__utils__.sendAJAX("url to API", 'POST', jsonObject, false, 
           {
              dataType: "json",
              headers:{
                  contentType: "application/json; charset=utf-8"
              }
           }));
  } catch (e) {
      console.log(e);
  }
  </code></pre>
  
  <p>Nothing is returned in the try/catch.  If I print the JSON.parse it is just HTML from my webpage asking for proper headings.</p>
  
  <p>I have tried different variations of settings and even tried passing nothing. For Example:</p>
  
  <pre><code>try {
      return JSON.parse(__utils__.sendAJAX("url to API", 'POST', jsonObject, false, null));
  } catch (e) {
      console.log(e);
  }
  </code></pre>
  
  <p>Still no luck.</p>