title: Request byte array from REST in Java
body: <p>according to this tutorial <a href="https://tutorial-academy.com/rest-jersey2-image-base64-download/" rel="nofollow noreferrer">Base64 download REST web service</a> I am trying to download from my client app, multiple images stored in a byte array who are send from my REST service. The REST resource file contains: </p>
  
  <pre><code>//****RESTful Service****
  @GET    // HTTP GET request
  @Path("get_pictures/{userid}")
  @Produces( MediaType.APPLICATION_OCTET_STREAM )
  // Gets all the pictures for the report
  public Response getReportPictures(@PathParam("userid") int userid) {
      return wsmanager.getReportPictures(userid);
  }
  </code></pre>
  
  <p>In the below getReportPicture() method I am serializing the images and store them in an ArrayList which I want to return via the above REST service. The Image class is one of my libs to serialize and unserialize pictures. The serializing process and returning the ArraList of byte[] works well.</p>
  
  <pre><code>    //**** getReportPicture() method *****
      ArrayList&lt;byte[]&gt; pictures = new ArrayList&lt;byte[]&gt;();
      ...
      Response response = null;
      ...
      byte[] img = Image.serialize(strPictureFile);       
      pictures.add(img);
      ... 
      ResponseBuilder builder = Response
          .ok( pictures, "image/jpg" )
          .header( "Content-Disposition","inline; filename = \"" + name + "\"" );
          response = builder.build();
  
      return response;
  </code></pre>
  
  <p>At my Java client I am trying to read the content from the REST service, which is not working implementing the below code:</p>
  
  <pre><code>    WebTarget target = baseTarget.path("get_pictures/"+userid);
      Response clResponse = target
              .request(MediaType.APPLICATION_OCTET_STREAM)
              .get();
      String s = clResponse.readEntity(String.class);
  </code></pre>
  
  <p>Can someone help please?.</p>