title: POST request using RCurl
body: <p>As a way of exploring how to make a package in R for the Denver RUG, I decided that it would be a fun little project to write an R wrapper around the datasciencetoolkit API.  The basic R tools come from the RCurl package as you might imagine.  I am stuck on a seemingly simple problem and I'm hoping that somebody in this forum might be able to point me in the right direction.  The basic problem is that I can't seem to use postForm() to pass an un-keyed string as part of the data option in curl, i.e. curl -d "string" "address_to_api".  </p>
  
  <p>For example, from the command line I might do</p>
  
  <pre><code>$ curl -d "Tim O'Reilly, Archbishop Huxley" "http://www.datasciencetoolkit.org/text2people"
  </code></pre>
  
  <p>with success.  However, it seems that postForm() requires an explicit key when passing additional arguments into the POST request.  I've looked through the datasciencetoolkit code and developer docs for a possible key, but can't seem to find anything.  </p>
  
  <p>As an aside, it's pretty straightforward to pass inputs via a GET request to other parts of the DSTK API.  For example, </p>
  
  <pre><code>ip2coordinates &lt;- function(ip) {
    api &lt;- "http://www.datasciencetoolkit.org/ip2coordinates/"
    result &lt;- getURL(paste(api, URLencode(ip), sep=""))
    names(result) &lt;- "ip"
    return(result)
  }
  ip2coordinates('67.169.73.113')
  </code></pre>
  
  <p>will produce the desired results. </p>
  
  <p>To be clear, I've read through the RCurl docs on DTL's omegahat site, the RCurl docs with the package, and the curl man page.  However, I'm missing something fundamental with respect to curl (or perhaps .opts() in the postForm() function) and I can't seem to get it.  </p>
  
  <p>In python, I could basically make a 'raw' POST request using httplib.HTTPConnection -- is something like that available in R?  I've looked at the simplePostToHost function in the httpRequest package as well and it just seemed to lock my R session (it seems to require a key as well). </p>
  
  <p>FWIW, I'm using R 2.13.0 on Mac 10.6.7.</p>
  
  <p>Any help is much appreciated.  All of the code will soon be available on github if you're interested in playing around with the data science toolkit.</p>
  
  <p>Cheers.</p>