title: getting binary data when using POST request in httr package
body: <p>I am using the POST function in httr library to get some data and the code is shown below.</p>
  
  <pre><code>library(httr)
  
  url = "https://xxxx:xxx@api.xxx/_search" #omitted for privacy
  a = POST(url,body = query,encode = "json")
  </code></pre>
  
  <p>The query is shown below in the appendix. <code>a$content</code> is giving me a whole bunch of a hexadecimal numbers on which I have to use another function before I can get some useful data. </p>
  
  <p>Ultimately I wish to get a data frame by using <code>b = fromJSON(a$content)</code>. So far in order to get any data I have to use:</p>
  
  <pre><code>chr&lt;-function(n){rawToChar(as.raw(n))}
  b = jsonlite::fromJSON(chr(a$content))
  data = b$hits$hits$`_source`
  </code></pre>
  
  <p>This seems inefficient considering that I am parsing in the data through a local function to get the final data. So my questions are as follows:</p>
  
  <ol>
  <li>Am I using the POST function correctly to get the query?</li>
  <li>Is there a more efficient (faster) way of getting my data into a data frame?</li>
  </ol>
  
  <p>Appendix:</p>
  
  <pre><code>query = '
  {
    "_source": [
      "start","source.country_codes",
      "dest.country_codes"
      ],
      "size": 100,
      "query": {
      "bool": {
      "must": [
      {
      "bool": {
      "must_not": [
      {
      "range": {
      "start": {
      "lte": "2013-01-01T00:00:00"
      }
      }
      },
      {
      "range": {
      "start": {
      "gt": "2016-05-19T00:00:00"
      }
      }
      }
      ]
      }
      }
      ]
      }
    }
  }'
  </code></pre>