How do I download the binary file?

This is the setting.
but…how do I download the binary from here? as the server return json as at bellow :

HttpResponseProxy{HTTP/1.1 201 Created [Date: Sat, 16 Sep 2017 13:54:59 GMT, Server: Apache, X-Frame-Options: SAMEORIGIN, Vary: Cookie, X-Powered-By: PHP/7.0.22, Cache-Control: no-cache, private, Content-Length: 87, Keep-Alive: timeout=5, max=99, Connection: Keep-Alive, Content-Type: application/json] ResponseEntityProxy{[Content-Type: application/json,Content-Length: 87,Chunked: false]}}

and this is my code :

    post = new HttpPost("http://localhost:8080/api/v2/files/5_6116365761188462595.docx?download=true");     

    post.setHeader("Content-Type", "application/docx");
    post.setHeader("Content-Disposition", "attachment; filename=5_6116365761188462595.docx");        
    post.setHeader("X-DreamFactory-Session-Token", ls_token );
    post.setHeader("X-Dreamfactory-API-Key", "36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88"); 
    paramList = new ArrayList<>();
    try {
    	post.setEntity(new UrlEncodedFormEntity(paramList));
    	response = httpclient.execute(post);

this is my dreamfactory setting :

ok, finally I solved the problem. Apache HttpClient will not work. OKHTTP or Retrofit work fine.

Please note that Apache HttpClient will cause deamfactory reset the binary file to zero byte

1 Like