Example usage for org.apache.http.entity.mime MultipartEntityBuilder build

List of usage examples for org.apache.http.entity.mime MultipartEntityBuilder build

Introduction

In this page you can find the example usage for org.apache.http.entity.mime MultipartEntityBuilder build.

Prototype

public HttpEntity build() 

Source Link

Usage

From source file:io.swagger.client.api.CameraApi.java

/**
* Activate autofocus on specified area (coordinates)
* 
* @param x    * @param y /*from   www  .  j a  va  2 s.c o  m*/
*/
public void autofocusPost(Integer x, Integer y, final Response.Listener<String> responseListener,
        final Response.ErrorListener errorListener) {
    Object postBody = null;

    // verify the required parameter 'x' is set
    if (x == null) {
        VolleyError error = new VolleyError("Missing the required parameter 'x' when calling autofocusPost",
                new ApiException(400, "Missing the required parameter 'x' when calling autofocusPost"));
    }

    // verify the required parameter 'y' is set
    if (y == null) {
        VolleyError error = new VolleyError("Missing the required parameter 'y' when calling autofocusPost",
                new ApiException(400, "Missing the required parameter 'y' when calling autofocusPost"));
    }

    // create path and map variables
    String path = "/autofocus".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> queryParams = new ArrayList<Pair>();
    // header params
    Map<String, String> headerParams = new HashMap<String, String>();
    // form params
    Map<String, String> formParams = new HashMap<String, String>();

    queryParams.addAll(ApiInvoker.parameterToPairs("", "x", x));
    queryParams.addAll(ApiInvoker.parameterToPairs("", "y", y));

    String[] contentTypes = {

    };
    String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";

    if (contentType.startsWith("multipart/form-data")) {
        // file uploading
        MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();

        HttpEntity httpEntity = localVarBuilder.build();
        postBody = httpEntity;
    } else {
        // normal form params
    }

    String[] authNames = new String[] {};

    try {
        apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams,
                contentType, authNames, new Response.Listener<String>() {
                    @Override
                    public void onResponse(String localVarResponse) {
                        responseListener.onResponse(localVarResponse);
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        errorListener.onErrorResponse(error);
                    }
                });
    } catch (ApiException ex) {
        errorListener.onErrorResponse(new VolleyError(ex));
    }
}

From source file:ch.ralscha.extdirectspring_itest.FileUploadServiceTest.java

@Test
public void testUpload() throws IOException {
    CloseableHttpClient client = HttpClientBuilder.create().build();
    CloseableHttpResponse response = null;
    try {//  www.j  a v  a 2 s .  co m

        HttpPost post = new HttpPost("http://localhost:9998/controller/router");

        InputStream is = getClass().getResourceAsStream("/UploadTestFile.txt");

        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        ContentBody cbFile = new InputStreamBody(is, ContentType.create("text/plain"), "UploadTestFile.txt");
        builder.addPart("fileUpload", cbFile);
        builder.addPart("extTID", new StringBody("2", ContentType.DEFAULT_TEXT));
        builder.addPart("extAction", new StringBody("fileUploadService", ContentType.DEFAULT_TEXT));
        builder.addPart("extMethod", new StringBody("uploadTest", ContentType.DEFAULT_TEXT));
        builder.addPart("extType", new StringBody("rpc", ContentType.DEFAULT_TEXT));
        builder.addPart("extUpload", new StringBody("true", ContentType.DEFAULT_TEXT));

        builder.addPart("name",
                new StringBody("Jim", ContentType.create("text/plain", Charset.forName("UTF-8"))));
        builder.addPart("firstName", new StringBody("Ralph", ContentType.DEFAULT_TEXT));
        builder.addPart("age", new StringBody("25", ContentType.DEFAULT_TEXT));
        builder.addPart("email", new StringBody("test@test.ch", ContentType.DEFAULT_TEXT));

        post.setEntity(builder.build());
        response = client.execute(post);
        HttpEntity resEntity = response.getEntity();

        assertThat(resEntity).isNotNull();
        String responseString = EntityUtils.toString(resEntity);

        String prefix = "<html><body><textarea>";
        String postfix = "</textarea></body></html>";
        assertThat(responseString).startsWith(prefix);
        assertThat(responseString).endsWith(postfix);

        String json = responseString.substring(prefix.length(), responseString.length() - postfix.length());

        ObjectMapper mapper = new ObjectMapper();
        Map<String, Object> rootAsMap = mapper.readValue(json, Map.class);
        assertThat(rootAsMap).hasSize(5);
        assertThat(rootAsMap.get("method")).isEqualTo("uploadTest");
        assertThat(rootAsMap.get("type")).isEqualTo("rpc");
        assertThat(rootAsMap.get("action")).isEqualTo("fileUploadService");
        assertThat(rootAsMap.get("tid")).isEqualTo(2);

        @SuppressWarnings("unchecked")
        Map<String, Object> result = (Map<String, Object>) rootAsMap.get("result");
        assertThat(result).hasSize(7);
        assertThat(result.get("name")).isEqualTo("Jim");
        assertThat(result.get("firstName")).isEqualTo("Ralph");
        assertThat(result.get("age")).isEqualTo(25);
        assertThat(result.get("e-mail")).isEqualTo("test@test.ch");
        assertThat(result.get("fileName")).isEqualTo("UploadTestFile.txt");
        assertThat(result.get("fileContents")).isEqualTo("contents of upload file");
        assertThat(result.get("success")).isEqualTo(Boolean.TRUE);

        EntityUtils.consume(resEntity);

        is.close();
    } finally {
        IOUtils.closeQuietly(response);
        IOUtils.closeQuietly(client);
    }
}

From source file:io.swagger.client.api.CameraApi.java

/**
* Activate autofocus on specified area (coordinates)
* 
 * @param x /* w  ww  .  java 2 s .  c  om*/
 * @param y 
 * @return void
*/
public void autofocusPost(Integer x, Integer y)
        throws TimeoutException, ExecutionException, InterruptedException, ApiException {
    Object postBody = null;

    // verify the required parameter 'x' is set
    if (x == null) {
        VolleyError error = new VolleyError("Missing the required parameter 'x' when calling autofocusPost",
                new ApiException(400, "Missing the required parameter 'x' when calling autofocusPost"));
    }

    // verify the required parameter 'y' is set
    if (y == null) {
        VolleyError error = new VolleyError("Missing the required parameter 'y' when calling autofocusPost",
                new ApiException(400, "Missing the required parameter 'y' when calling autofocusPost"));
    }

    // create path and map variables
    String path = "/autofocus".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> queryParams = new ArrayList<Pair>();
    // header params
    Map<String, String> headerParams = new HashMap<String, String>();
    // form params
    Map<String, String> formParams = new HashMap<String, String>();

    queryParams.addAll(ApiInvoker.parameterToPairs("", "x", x));
    queryParams.addAll(ApiInvoker.parameterToPairs("", "y", y));

    String[] contentTypes = {

    };
    String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";

    if (contentType.startsWith("multipart/form-data")) {
        // file uploading
        MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create();

        HttpEntity httpEntity = localVarBuilder.build();
        postBody = httpEntity;
    } else {
        // normal form params
    }

    String[] authNames = new String[] {};

    try {
        String localVarResponse = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody,
                headerParams, formParams, contentType, authNames);
        if (localVarResponse != null) {
            return;
        } else {
            return;
        }
    } catch (ApiException ex) {
        throw ex;
    } catch (InterruptedException ex) {
        throw ex;
    } catch (ExecutionException ex) {
        if (ex.getCause() instanceof VolleyError) {
            VolleyError volleyError = (VolleyError) ex.getCause();
            if (volleyError.networkResponse != null) {
                throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
            }
        }
        throw ex;
    } catch (TimeoutException ex) {
        throw ex;
    }
}

From source file:ch.ralscha.extdirectspring_itest.FileUploadControllerTest.java

@Test
public void testUpload() throws IOException {
    CloseableHttpClient client = HttpClientBuilder.create().build();
    InputStream is = null;/* www. j a  v  a2  s.c  om*/
    CloseableHttpResponse response = null;

    try {
        HttpPost post = new HttpPost("http://localhost:9998/controller/router");
        is = getClass().getResourceAsStream("/UploadTestFile.txt");

        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        ContentBody cbFile = new InputStreamBody(is, ContentType.create("text/plain"), "UploadTestFile.txt");
        builder.addPart("fileUpload", cbFile);
        builder.addPart("extTID", new StringBody("2", ContentType.DEFAULT_TEXT));
        builder.addPart("extAction", new StringBody("fileUploadController", ContentType.DEFAULT_TEXT));
        builder.addPart("extMethod", new StringBody("uploadTest", ContentType.DEFAULT_TEXT));
        builder.addPart("extType", new StringBody("rpc", ContentType.DEFAULT_TEXT));
        builder.addPart("extUpload", new StringBody("true", ContentType.DEFAULT_TEXT));

        builder.addPart("name",
                new StringBody("Jim", ContentType.create("text/plain", Charset.forName("UTF-8"))));
        builder.addPart("firstName", new StringBody("Ralph", ContentType.DEFAULT_TEXT));
        builder.addPart("age", new StringBody("25", ContentType.DEFAULT_TEXT));
        builder.addPart("email", new StringBody("test@test.ch", ContentType.DEFAULT_TEXT));

        post.setEntity(builder.build());
        response = client.execute(post);
        HttpEntity resEntity = response.getEntity();

        assertThat(resEntity).isNotNull();
        String responseString = EntityUtils.toString(resEntity);

        String prefix = "<html><body><textarea>";
        String postfix = "</textarea></body></html>";
        assertThat(responseString).startsWith(prefix);
        assertThat(responseString).endsWith(postfix);

        String json = responseString.substring(prefix.length(), responseString.length() - postfix.length());

        ObjectMapper mapper = new ObjectMapper();
        Map<String, Object> rootAsMap = mapper.readValue(json, Map.class);
        assertThat(rootAsMap).hasSize(5);
        assertThat(rootAsMap.get("method")).isEqualTo("uploadTest");
        assertThat(rootAsMap.get("type")).isEqualTo("rpc");
        assertThat(rootAsMap.get("action")).isEqualTo("fileUploadController");
        assertThat(rootAsMap.get("tid")).isEqualTo(2);

        @SuppressWarnings("unchecked")
        Map<String, Object> result = (Map<String, Object>) rootAsMap.get("result");
        assertThat(result).hasSize(7);
        assertThat(result.get("name")).isEqualTo("Jim");
        assertThat(result.get("firstName")).isEqualTo("Ralph");
        assertThat(result.get("age")).isEqualTo(25);
        assertThat(result.get("email")).isEqualTo("test@test.ch");
        assertThat(result.get("fileName")).isEqualTo("UploadTestFile.txt");
        assertThat(result.get("fileContents")).isEqualTo("contents of upload file");
        assertThat(result.get("success")).isEqualTo(Boolean.TRUE);

        EntityUtils.consume(resEntity);
    } finally {
        IOUtils.closeQuietly(response);
        IOUtils.closeQuietly(is);
        IOUtils.closeQuietly(client);
    }
}

From source file:org.brutusin.rpc.client.http.HttpEndpoint.java

private CloseableHttpResponse doExec(String serviceId, JsonNode input, HttpMethod httpMethod,
        final ProgressCallback progressCallback) throws IOException {
    RpcRequest request = new RpcRequest();
    request.setJsonrpc("2.0");
    request.setMethod(serviceId);/*from   ww  w . j a  v  a 2  s .  com*/
    request.setParams(input);
    final String payload = JsonCodec.getInstance().transform(request);
    final HttpUriRequest req;
    if (httpMethod == HttpMethod.GET) {
        String urlparam = URLEncoder.encode(payload, "UTF-8");
        req = new HttpGet(this.endpoint + "?jsonrpc=" + urlparam);
    } else {
        HttpEntityEnclosingRequestBase reqBase;
        if (httpMethod == HttpMethod.POST) {
            reqBase = new HttpPost(this.endpoint);
        } else if (httpMethod == HttpMethod.PUT) {
            reqBase = new HttpPut(this.endpoint);
        } else {
            throw new AssertionError();
        }
        req = reqBase;
        HttpEntity entity;
        Map<String, InputStream> files = JsonCodec.getInstance().getStreams(input);
        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        builder.setMode(HttpMultipartMode.STRICT);
        builder.addPart("jsonrpc", new StringBody(payload, ContentType.APPLICATION_JSON));
        if (files != null && !files.isEmpty()) {
            files = sortFiles(files);
            for (Map.Entry<String, InputStream> entrySet : files.entrySet()) {
                String key = entrySet.getKey();
                InputStream is = entrySet.getValue();
                if (is instanceof MetaDataInputStream) {
                    MetaDataInputStream mis = (MetaDataInputStream) is;
                    builder.addPart(key, new InputStreamBody(mis, mis.getName()));
                } else {
                    builder.addPart(key, new InputStreamBody(is, key));
                }
            }
        }
        entity = builder.build();
        if (progressCallback != null) {
            entity = new ProgressHttpEntityWrapper(entity, progressCallback);
        }
        reqBase.setEntity(entity);
    }
    HttpClientContext context = contexts.get();
    if (this.clientContextFactory != null && context == null) {
        context = clientContextFactory.create();
        contexts.set(context);
    }
    return this.httpClient.execute(req, context);
}

From source file:nzilbb.bas.BAS.java

/**
 * Invoke the MaryTTS German Text-to-speech service.
 * @param INPUT_TYPE One of:/*from  w  w  w  .  j  a  v  a2s  . c  om*/
 *  <ul>
 *   <li>"TEXT"</li>
 *   <li>"SIMPLEPHONEMES"</li>
 *   <li>"SABLE"</li>
 *   <li>"SSML"</li>
 *   <li>"APML"</li>
 *   <li>"PHONEMES"</li>
 *   <li>"INTONATION"</li>
 *   <li>"ACOUSTPARAMS"</li>
 *   <li>"RAWMARYXML"</li>
 *   <li>"TOKENS"</li>
 *   <li>"WORDS"</li>
 *   <li>"ALLOPHONES"</li>
 *   <li>"REALISED_ACOUSTPARAMS"</li>
 *   <li>"REALISED_DURATIONS"</li>
 *   <li>"PRAAT_TEXTGRID"</li>
 *   <li>"PARTSOFSPEECH"</li>
 *  </ul>
 * @param INPUT_TEXT The text input.
 * @param OUTPUT_TYPE One of:
 *  <ul>
 *   <li>"PHONEMES"</li>
 *   <li>"INTONATION"</li>
 *   <li>"ACOUSTPARAMS"</li>
 *   <li>"RAWMARYXML"</li>
 *   <li>"TOKENS"</li>
 *   <li>"WORDS"</li>
 *   <li>"ALLOPHONES"</li>
 *   <li>"REALISED_ACOUSTPARAMS"</li>
 *   <li>"REALISED_DURATIONS"</li>
 *   <li>"PRAAT_TEXTGRID"</li>
 *   <li>"PARTSOFSPEECH"</li>
 *   <li>"AUDIO"</li>
 *   <li>"HALFPHONE_TARGETFEATURES"</li>
 *  </ul>
 * @param AUDIO If <var>OUTPUT_TYPE</var> = "AUDIO", this can be one of:
 *  <ul>
 *   <li>"WAVE_FILE"</li>
 *   <li>"AU_FILE"</li>
 *   <li>"AIFF_FILE"</li>
 *  </ul>
 * @param VOICE One of:
 *  <ul>
 *   <li>"bits4unitselautolabel"</li>
 *   <li>"bits3unitselautolabel"</li>
 *   <li>"bits3"</li>
 *   <li>"bits2unitselautolabel"</li>
 *   <li>"bits1unitselautolabel"</li>
 *   <li>"bits4unitselautolabelhmm"</li>
 *   <li>"bits3unitselautolabelhmm"</li>
 *   <li>"bits3-hsmm"</li>
 *   <li>"bits2unitselautolabelhmm"</li>
 *   <li>"bits1unitselautolabelhmm"</li>
 *  </ul>    
 * @return The response to the request.
 * @throws IOException If an IO error occurs.
 * @throws ParserConfigurationException If the XML parser for parsing the response could not be configured.
 */
public BASResponse TTS(String INPUT_TYPE, InputStream INPUT_TEXT, String OUTPUT_TYPE, String AUDIO,
        String VOICE) throws IOException, ParserConfigurationException {
    if (VOICE == null)
        VOICE = "bits1unitselautolabel";
    HttpPost request = new HttpPost(getTTSUrl());
    MultipartEntityBuilder builder = MultipartEntityBuilder.create().addTextBody("INPUT_TYPE", INPUT_TYPE)
            .addBinaryBody("INPUT_TEXT", INPUT_TEXT, ContentType.create("text/plain"), "BAS.txt")
            .addTextBody("OUTPUT_TYPE", OUTPUT_TYPE).addTextBody("AUDIO", AUDIO).addTextBody("VOICE", VOICE);
    HttpEntity entity = builder.build();
    request.setEntity(entity);
    HttpResponse httpResponse = httpclient.execute(request);
    HttpEntity result = httpResponse.getEntity();
    return new BASResponse(result.getContent());
}

From source file:com.intuit.tank.httpclient4.TankHttpClient4.java

private HttpEntity buildParts(BaseRequest request) {
    MultipartEntityBuilder builder = MultipartEntityBuilder.create();
    for (PartHolder h : TankHttpUtil.getPartsFromBody(request)) {
        if (h.getFileName() == null) {
            if (h.isContentTypeSet()) {
                builder.addTextBody(h.getPartName(), new String(h.getBodyAsString()),
                        ContentType.create(h.getContentType()));
            } else {
                builder.addTextBody(h.getPartName(), new String(h.getBodyAsString()));
            }/*from w w w.j  a  va  2s.c om*/
        } else {
            if (h.isContentTypeSet()) {
                builder.addBinaryBody(h.getPartName(), h.getBody(), ContentType.create(h.getContentType()),
                        h.getFileName());
            } else {
                builder.addBinaryBody(h.getFileName(), h.getBody());
            }
        }
    }
    return builder.build();
}

From source file:org.openbaton.marketplace.core.VNFPackageManagement.java

public void dispatch3(VNFPackageMetadata packageMetadata) throws IOException, ArchiveException, SDKException {
    log.debug("Trying to upload package to FITEagle");

    String url = "http://" + fitEagleIp + ":" + fitEaglePort + "/OpenBaton/upload/v2";

    log.debug("FITEagle URL is: " + url);

    //    HttpClient client = HttpClientBuilder.create().build();
    HttpClient client = HttpClients.createDefault();
    HttpPost request = new HttpPost(url);

    MultipartEntityBuilder builder = MultipartEntityBuilder.create();

    byte[] vnfPackageFile = packageMetadata.getVnfPackageFile();
    log.debug("Trying to add binary file of length: " + vnfPackageFile.length);
    builder.addBinaryBody("file", vnfPackageFile, ContentType.APPLICATION_OCTET_STREAM,
            packageMetadata.getName());/*from   ww  w .  j av a 2s  .  c o  m*/

    String currentUser = userManagement.getCurrentUser();
    request.addHeader("username", currentUser);
    log.debug("Added username header: " + currentUser);

    request.setEntity(builder.build());
    log.debug("Added binary file of length: " + vnfPackageFile.length);
    HttpResponse response = client.execute(request);
    log.debug("Executed POST!");
    log.debug("Response Code from FITEAGLE: " + response.getStatusLine().getStatusCode());
}

From source file:org.piwigo.remotesync.api.client.WSClient.java

@SuppressWarnings("unchecked")
protected <T extends BasicResponse> CloseableHttpResponse getHttpResponse(AbstractRequest<T> request)
        throws ClientException {
    try {//  w  w w  .j a  va  2  s.  c  om
        HttpPost method = new HttpPost(clientConfiguration.getUrl() + "/ws.php");
        method.setConfig(requestConfig);

        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
        multipartEntityBuilder.addTextBody("method", request.getWSMethodName());
        for (Entry<String, Object> entry : request.getParameters().entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (value instanceof File)
                multipartEntityBuilder.addBinaryBody(key, (File) value);
            else if (value == null)
                multipartEntityBuilder.addTextBody(key, "");
            else if (value instanceof List) {
                for (Object object : (List<? extends Object>) value)
                    if (object != null)
                        multipartEntityBuilder.addTextBody(key + "[]", object.toString());
            } else if (value instanceof Enum)
                multipartEntityBuilder.addTextBody(key, value.toString().toLowerCase());
            else
                multipartEntityBuilder.addTextBody(key, value.toString());
        }
        method.setEntity(multipartEntityBuilder.build());

        return getHttpClient().execute(method);
    } catch (SSLException e) {
        throw new ClientSSLException("SSL certificate exception (Please try option 'Trust SSL certificates')",
                e);
    } catch (Exception e) {
        throw new ClientException("Unable to send request", e);
    }
}

From source file:nzilbb.bas.BAS.java

/**
 * Invoke the TextAlign service for aligning two representations of text, e.g. letters in orthographic transcript with phonemes in a phonemic transcription.
 * @param i CSV text file with two semicolon-separated columns. Each row contains a sequence pair to be aligned. The sequence elements must be separated by a blank. Example: a word and its canonical transcription like S c h e r z;S E6 t s.
 * @param cost Cost function for the edit operations substitution, deletion, and insertion to be used for the alignment.
 * <ul>/*from  w w  w.ja va 2  s  .com*/
 *  <li>"naive" - assigns cost 1 to all operations except of null-substitution, i.e. the substitution of a symbol by itself, which receives cost 0. This 'naive' cost function should be used only if the pairs to be aligned share the same vocabulary, which is NOT the case e.g. in grapheme-phoneme alignment (grapheme 'x' is not the same as phoneme 'x').</li>
 *  <li>"g2p_deu", "g2p_eng" etc. are predefined cost functions for grapheme-phoneme alignment for the respective language expressed as iso639-3.</li>
 *  <li>"intrinsic" -  a cost function is trained on the input data and returned in the output zip. Costs are derived from co-occurrence probabilities, thus the bigger the input file, the more reliable the emerging cost function.</li> 
 *  <li>"import" - the user can provide his/her own cost function file, that must be a semicolon-separated 3-column csv text file. Examples: v;w;0.7 - the substitution of 'v' by 'w' costs 0.7. v;_;0.8 - the delition of 'v' costs 0.8; _;w;0.9 - the insertion of 'w' costs 0.9. A typical usecase is to train a cost function on a big data set with cost='intrinsic', and to subsequently apply this cost function on smaller data sets with cost='import'.</li>
 * </ul>
 * @param costfile CSV text file with three semicolon-separated columns. Each row contains three columns of the form a;b;c, where c denotes the cost for substituting a by b. Insertion and deletion are are marked by an underscore.
 * @param displc whether alignment costs should be displayed in a third column in the output file. 
 * @param atype Alignment type:
 *  <ul>
 *   <li>"dir" - align the second column to the first.</li>
 *   <li>"sym" symmetric alignment.</li>
 *  </ul>
 * @return The response to the request.
 * @throws IOException If an IO error occurs.
 * @throws ParserConfigurationException If the XML parser for parsing the response could not be     */
public BASResponse TextAlign(InputStream i, String cost, InputStream costfile, Boolean displc, String atype)
        throws IOException, ParserConfigurationException {
    if (displc == null)
        displc = Boolean.FALSE;
    if (atype == null)
        atype = "dir";
    HttpPost request = new HttpPost(getTextAlignUrl());
    MultipartEntityBuilder builder = MultipartEntityBuilder.create()
            .addBinaryBody("i", i, ContentType.create("text/csv"), "BAS.csv").addTextBody("cost", cost)
            .addTextBody("displc", displc ? "yes" : "no").addTextBody("atype", atype);
    if (costfile != null)
        builder.addBinaryBody("costfile", costfile, ContentType.create("text/csv"), "BAS.cst.csv");
    HttpEntity entity = builder.build();
    request.setEntity(entity);
    HttpResponse httpResponse = httpclient.execute(request);
    HttpEntity result = httpResponse.getEntity();
    return new BASResponse(result.getContent());
}