title: Get binary document from QueryResult Couchbase response
body: <p>I am using Couchbase 3.2 SDK, to query couchbase server. Like below</p>
  <pre><code>QueryResult result = cluster.query(
                      &quot;SELECT *, Meta().id FROM  bucketName USE KEYS ?&quot;,
                      queryOptions().parameters(JsonArray.from(&quot;pk&quot;)).readonly(true));
  </code></pre>
  <p>The response is like</p>
  <pre><code>[{&quot;id&quot;:&quot;pk&quot;,&quot;bucketName&quot;:&quot;&lt;binary (21 b)&gt;&quot;}]
  </code></pre>
  <p>My Document is a byte[], How can I get byte[] from the query response.
  <strong>I have tried</strong></p>
  <ol>
  <li>parsing to custom object by doing
  <pre><code>result.rowsAs(CustomClass.class)
  </code></pre>
  </li>
  <li>Also tried
  <pre><code>for (JsonObject row : result.rowsAsObject()) {
               resposne.put((String) row.get(&quot;id&quot;), ((String)row.get(&quot;ratingsAndReviewCollection&quot;)).getBytes(&quot;UTF-8&quot;));
           }
  </code></pre>
  </li>
  </ol>
  <p>but both of them does not return the same doc that i had put.</p>
  <p><a href="https://forums.couchbase.com/t/how-to-convert-n1ql-query-results-to-binarydocuments/12088" rel="nofollow noreferrer">This</a> thread talks about this but does not give clear solution to this.</p>