2 Replies Latest reply on Sep 11, 2017 3:37 PM by bibek karki

    Error 400 while publishing workbook via Tableau REST API 2.4

    bibek karki

      Hello all,

       

      I am trying to publish a workbook (twbx file) in Tableau online server.

       

      Things I have used:

      Post Url : https://myserver/api/2.4/sites/siteId/workbooks

       

      Headers:

                  connection.setRequestProperty("X-Tableau-Auth", token);

                 connection.setRequestProperty("Content-Type", "multipart/mixed; boundary=" + boundaryStr);

                 connection.setRequestProperty("Content-Length", Integer.toString(len));

       

      len = body.length;

       

      where body is :

       

      --892d87f37e614f56b8b452d8b6d2cb78

      Content-Disposition: name="request_payload"

      Content-Type: text/xml

       

       

      <tsRequest>

        <workbook name="name_" showTabs="true">

          <connectionCredentials name="name_" password="password_"/>

          <project id="Id"/>

        </workbook>

      </tsRequest>

       

       

      --892d87f37e614f56b8b452d8b6d2cb78

      Content-Disposition: name="tableau_workbook"; filename="New Text Document.twbx"

      Content-Type: application/octet-stream

       

       

      Hello ALL !! (content of file that is to be published)

       

       

      --892d87f37e614f56b8b452d8b6d2cb78--

       

      And, the response I'm getting is error 400 since couple of days. I think 400 means malformed xml, what could be wrong here ? Would you please help me to pave the way forward to solve this problem ?

       

      Thank You.

        • 1. Re: Error 400 while publishing workbook via Tableau REST API 2.4
          Glen Robinson

          Hi Bibek

          Can you confirm that the request body is correctly formed.

          The main thing i had to make sure of was  the number of blank lines.

          So for yours it should look like this, i think

           

          --892d87f37e614f56b8b452d8b6d2cb78

          Content-Disposition: name="request_payload"

          Content-Type: text/xml

           

          <tsRequest>

            <workbook name="name_" showTabs="true">

              <connectionCredentials name="name_" password="password_"/>

              <project id="Id"/>

            </workbook>

          </tsRequest>

            --892d87f37e614f56b8b452d8b6d2cb78

          Content-Disposition: name="tableau_workbook"; filename="New Text Document.twbx"

          Content-Type: application/octet-stream

           

          Hello ALL !! (content of file that is to be published)

          --892d87f37e614f56b8b452d8b6d2cb78--

           

          good luck

          Glen

          • 2. Re: Error 400 while publishing workbook via Tableau REST API 2.4
            bibek karki

            Thanks for the reply, Glen.

             

            I used another library to call REST API (HTTPClient) and it worked.

             

            Earlier, I had used HTTP URL connection and had to spend a lot of time to format payload which didn't work.