1 2 Previous Next 17 Replies Latest reply on Jan 21, 2016 5:51 PM by Ben Lower

    Java HttpClient/HttpMime example for publishing Data sources

    Jim B

      Currently using HttpClient and getting an Http 500 (tableau online).  There is an html response indicating missing boundary.  Below is how I am building the entity using httpclient/httpmime libraries (4.3.x):

      ....

      HttpEntity entity = MultipartEntityBuilder

        .create()

        .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)  // tried skipping this too and same result

        .addTextBody("request_payload", payload, ContentType.TEXT_XML)

        .addBinaryBody("tableau_datasource", tempFile)

        .build();

       

      HttpEntityEnclosingRequestBase uriRequest =

         new HttpPost(url.toURI());
      uriRequest.setEntity(entity);
      uriRequest.setHeaders(headerList.toArray(new Header[0]));
      CloseableHttpResponse response;
      try {

        response = httpClient.execute(uriRequest);

      ....

       

      This is a trace log of the outgoing content:

      --E0CJOm_bsS5zubIQxd51thY7jjkxLEGlEvNcF

      Content-Disposition: form-data; name="request_payload"

      Content-Type: text/plain; charset=ISO-8859-1

      Content-Transfer-Encoding: 8bit

       

       

      <?xml version="1.0" encoding="UTF-8"?><tsRequest><datasource name="TDE_2014-12-12T043121787-0800"><connectionCredentials embed="True" name="***" password="***"/><project id="default"/><tags>        </tags></datasource><favorite><workbook><tags>            </tags><views>            </views></workbook></favorite><permissions><datasource><tags>            </tags></datasource><workbook><tags>            </tags><views>            </views></workbook></permissions><tags>    </tags><workbook><tags>        </tags><views>        </views></workbook></tsRequest>

      --E0CJOm_bsS5zubIQxd51thY7jjkxLEGlEvNcF

      Content-Disposition: form-data; name="tableau_datasource"; filename="TDE_2014-12-12T043121787-0800"

      Content-Type: application/octet-stream

      Content-Transfer-Encoding: binary

       

       

        bversion-fix:0

      version-major:1

      version-minor:0

      ...

       

       

      Any suggestions on the coding or what may be wrong with the content (user and password asterisked out)?

        1 2 Previous Next