2 Replies Latest reply on Feb 22, 2016 6:05 AM by Peter Jones

    Rest API publish workbook example - 500 error

    kf tang

      Hi, I have been following the Python 2.0 REST API sample, but I got stuck when trying to upload the sample workbook (both publish_simple and publish_with_chunk don't work). Using publish_simple I get a 500 error, but I didn't change anything in the sample code. My request looks like this (using httpbin.org/post to see my post request):

       

      "headers": {

        "Accept": "*/*",

        "Accept-Encoding": "gzip, deflate",

        "Content-Length": "176055",

        "Content-Type": "multipart/mixed; boundary=eb3382c1e800409ba9072b324cb39d07",

        "Host": "httpbin.org",

        "User-Agent": "python-requests/2.9.1",

        "X-Tableau-Auth": "k5mIJLnavmYOJdqyMmZ9qLadq5WAwGcs"

        }

       

      The payload looks like this:

      --2cc67e30aa8645ec94b804a2f5f245e1

      Content-Disposition: form-data; name="tableau_workbook"; filename="/Users/funplus/Downloads/rest-api-python-sample/RESTAPISample.twbx"

      Content-Type: application/octet-stream

      [binary content]

      --2cc67e30aa8645ec94b804a2f5f245e1

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

      Content-Type: text/xml

       

      <tsRequest><workbook name="test"><project id="ca45f406-59aa-4b45-b20b-6c9036a7f578" /></workbook></tsRequest>

      --2cc67e30aa8645ec94b804a2f5f245e1--

       

      Can someone tell me what I am doing wrong here? Many thanks!

        • 1. Re: Rest API publish workbook example - 500 error

          Hey Kf,

           

          I've moved this post to the REST API portion of our Community where you are more likely to receive a helpful response.

           

          -Diego

          • 2. Re: Rest API publish workbook example - 500 error
            Peter Jones

            From the documentation:

            --boundary-string

            Content-Disposition: name="request_payload"

            Content-Type: text/xml

             

            <tsRequest>

              <workbook name="workbook-name" showTabs="show-tabs-flag" >

              <connectionCredentials name="connection-username" password="connection-password"

              embed="embed-flag" />

              <project id="project-id"/>

              </workbook>

            </tsRequest>

            --boundary-string

            Content-Disposition: name="tableau_workbook"; filename="workbook-file-name"

            Content-Type: application/octet-stream

             

            content-of-workbook-file

            --boundary-string--

             

            And to me it appears you have the [Binary content] in the wrong place in your http message body, See below corrections:

            --2cc67e30aa8645ec94b804a2f5f245e1

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

            Content-Type: text/xml

             

            <tsRequest><workbook name="test"><project id="ca45f406-59aa-4b45-b20b-6c9036a7f578" /></workbook></tsRequest>

            --2cc67e30aa8645ec94b804a2f5f245e1

            Content-Disposition: form-data; name="tableau_workbook"; filename="/Users/funplus/Downloads/rest-api-python-sample/RESTAPISample.twbx"

            Content-Type: application/octet-stream

             

            [binary content]

            --2cc67e30aa8645ec94b804a2f5f245e1--

             

            Though I'm not the expert at this for sure maybe it will work for you.