title: httr POST request to API returns 400 error
body: <p>I'm working with the httr package in R in an attempt to query the postcode.io API (<a href="http://postcodes.io/docs" rel="nofollow">http://postcodes.io/docs</a>).</p>
  
  <p>I can successfully query a single postcode as per the instructions using:
  <code>sample4 &lt;- GET("api.postcodes.io/postcodes/EN14RF")</code></p>
  
  <p>When I try and query multiple postcodes I'm becoming a little unstuck. The postcode.io instructions suggest</p>
  
  <pre><code>POST https://api.postcodes.io/postcodes?q=[postcode]
  </code></pre>
  
  <p>where a JSON object containing an array of postcodes is specified. I have an R vector containing postcodes which I have attempted to convert to a JSON object as such with:</p>
  
  <pre><code>a &lt;- toJSON(a)
  </code></pre>
  
  <p>where my R vector 'a' is:</p>
  
  <pre><code>structure(c(4L, 5L, 3L, 6L, 1L, 2L), .Label = c("Bn14 9aw", "CR0 4BE", "E5 8HB", "EN1 4RF", "G42 8QN", "SA1 3UL"), class = "factor")
  </code></pre>
  
  <p>Now when I try and query the API with the following line of code:</p>
  
  <pre><code>sample4 &lt;- POST("https://api.postcodes.io/postcodes?q=[postcode]", body = list(postcode = add1JSON))
  </code></pre>
  
  <p>I get an error: <code>"Invalid JSON submitted. You need to submit a JSON object with an array of postcodes or geolocation objects"</code></p>
  
  <p>I have a feeling this is because I am not providing an array but an unnamed list e.g. my JSON object should look like this:</p>
  
  <pre><code>{"postcodes":"[ \"EN14RF\", \"G428QN\", \"E58HB\", \"SA13UL\", \"Bn149aw\", \"CR04BE\" ]"}
  </code></pre>
  
  <p>Not this: <code>"[ \"EN14RF\", \"G428QN\", \"E58HB\", \"SA13UL\", \"Bn149aw\", \"CR04BE\" ]"</code></p>
  
  <p>Can anyone help me with this? I've a feeling it is something to do with my <code>toJSON</code> call,  but have been unable to find a similar example on the forum or on the API developers page:(</p>
  
  <p>Many thanks</p>
  
  <p>Marty</p>