public ListenableFuture sendPost()

in templates/java/src/main/java/com/facebook/ads/sdk/APIRequest.java [639:672]


    public ListenableFuture<ResponseWrapper> sendPost(String apiUrl, Map<String, Object> allParams, APIContext context) throws APIException, IOException {
      String boundary = "--------------------------" + new Random().nextLong();
      okhttp3.MultipartBody.Builder builder = new okhttp3.MultipartBody.Builder(boundary)
          .setType(okhttp3.MultipartBody.FORM);
      for (Map.Entry<String, Object> entry : allParams.entrySet()) {
        if (entry.getValue() instanceof File) {
          File file = (File) entry.getValue();
          String contentType = RequestHelper.getContentTypeForFile(file);
          builder.addFormDataPart(
            entry.getKey(),
            file.getName(),
            okhttp3.RequestBody.create(okhttp3.MediaType.parse(contentType), file)
          );
        } else if (entry.getValue() instanceof byte[]) {
          builder.addFormDataPart(
            entry.getKey(),
            "chunkfile",
            okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/octet-stream"), (byte[])entry.getValue())
          );
        } else {
          builder.addFormDataPart(
            entry.getKey(),
            convertToString(entry.getValue())
          );
        }
      }
      okhttp3.Request request = new okhttp3.Request
        .Builder()
        .url(apiUrl)
        .post(builder.build())
        .header("User-Agent", USER_AGENT)
        .build();
      return RequestHelper.invoke(client, request);
    }