1 2 Previous Next 15 Replies Latest reply on Sep 1, 2016 10:28 AM by Ryan B

    Internal Server Error With Publish Datasource Method

    Diane Economides

      Hi,

       

      I'm receiving an error with the Publish Datasource method using the REST API.  I'm manually calling it through Fiddler and am able to sign in and query projects, so I'm not sure if this is due to a syntax error or something else. 

       

      Here's the URI, header and request body - I've taken out the server name and site id as well as the project id and user account credentials, but everything else appears exactly the same. 

       

      URI:  http://<my tableau server>/api/2.2/sites/<my site id>/datasources?overwrite=true

       

      Header:

       

      X-Tableau-Auth: 9XfgLeXQH7jIJtNtpVmUem2Qn8UaRBEN

      Content-Type: multipart/mixed; boundary=6691a87289ac461bab2c945741f136e6

       

      Request Body:

       

      --6691a87289ac461bab2c945741f136e6

      Content-Disposition: name="request_payload"

      Content-Type: text/xml

       

      <tsRequest>

        <datasource name="api_test_datasource">

              <connectionCredentials name="<user account name>" password="<user account password>"

                  embed="True" />

          <project id="<my project id>"/>

        </datasource>

      </tsRequest>

       

      --6691a87289ac461bab2c945741f136e6

      Content-Disposition: name="tableau_datasource"; filename="C:\Users\deconomides\Documents\My Tableau Repository\Datasources\api_test_datasource.tdsx"

      Content-Type: application/octet-stream

       

      --6691a87289ac461bab2c945741f136e6--

       

      Here's the response that I'm receiving for the error:

       

      <?xml version='1.0' encoding='UTF-8'?><tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.1.2.xsd">

      <error code="500000">

      <summary>Internal Server Error</summary>

      <detail>The server encountered an error and cannot complete your request. Contact your server administrator.</detail>

      </error>

      </tsResponse>

       

      There's not much detail in terms of the error, and I found this post that references the same error message, but it didn't resolve the problem.  Any insight that anyone can provide is greatly appreciated!

        • 1. Re: Internal Server Error With Publish Datasource Method
          Patrick Abernathy

          Hey Diane.  I'm actually in the current situation as well though I'm getting a 400 error.  One thing I'm using to help debug the issue is to check your log files.  By default, the file you're looking for is located at C:\ProgramData\Tableau\Tableau Server\data\tabsvc\logs\vizportal.  The file vizportal-0.log traps the server error message and will help you get a better view of what's going wrong.

          • 2. Re: Internal Server Error With Publish Datasource Method
            Diane Economides

            Thanks Patrick, that's a helpful tip.  My coworker ended up writing a VB script and got this working, but we still don't know why it wouldn't execute properly with manual calls through Postman and Fiddler. 

            • 3. Re: Internal Server Error With Publish Datasource Method
              Ryan B

              I'm also seeing this REST API 500 error when trying to publish a data source. I've double checked my headers, content length, multipart/mixed syntax, boundary syntax, etc. I've also looked at Re: REST API Publish Datasource "500 Internal Server error", which was useful, but didn't fix it for me. Anyone else have any ideas? Thanks in advance!

              • 4. Re: Internal Server Error With Publish Datasource Method
                Patrick Abernathy

                Hey Ryan.  If you look into your log directory and find the vizportal-0.log file, what exception are you getting?  By default this file is located at C:\ProgramData\Tableau\Tableau Server\data\tabsvc\logs\vizportal.  I originally got the 500 error due to messing up the multipart header.  The correct header is "Content-type: multipart/mixed; boundary=boundary-string".  Boundary-string in the header should not contain the --.

                • 5. Re: Internal Server Error With Publish Datasource Method
                  Ryan B

                  Thanks for the reply, Patrick! I'm actually using Tableau Online, not Server, so I don't have access to those logs. I could set up Server and debug against it, but that's a bit of work, so it'd be nice to avoid if I don't have to.

                   

                  My Content-Type header does look like that example, though, and the boundary string doesn't have any dashes in it.

                  • 6. Re: Internal Server Error With Publish Datasource Method
                    Patrick Abernathy

                    Well that probably makes things a bit more difficult.  You could possibly request the exception from Tableau Support but I'm not sure.  What are you using to send the request?

                    • 7. Re: Internal Server Error With Publish Datasource Method
                      Ryan B

                      I'm taking with a rep today, so I'll mention it to them.

                       

                      I've tried Python requests, Python urllib2, and curl, all with the same result.

                      • 8. Re: Internal Server Error With Publish Datasource Method
                        Ryan B

                        Still no luck. I also tried the multi-part upload flow, and got the same result: opaque 500 error on step 2, append, which is a similar multipart/mixed request.

                         

                        I'd kill for an error message with any detail at all at this point. :/

                        • 9. Re: Internal Server Error With Publish Datasource Method
                          Patrick Abernathy

                          Hey Ryan.  Hate that you can't get the error files out.  The biggest problem I had with this request is getting all the spacing correct.  It's incredibly picky.  Unfortunately I don't know Python, but I've attached my C# wrapper that I use to publish the data source.  I can help you break it down if you're having in troubles with it.  Hoping at least seeing a different solution might help you find your issue.

                          • 10. Re: Internal Server Error With Publish Datasource Method
                            Ryan B

                            thanks patrick! much appreciated. fingers crossed...

                            • 11. Re: Internal Server Error With Publish Datasource Method
                              Ryan B

                              ok, making some progress. i've reproduced this against tableau server, and i have the exception from its vizportal-0.log file:

                               

                              org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly

                                  at com.tableausoftware.api.rest.util.RestApiMultipartResolver.parseRequest(RestApiMultipartResolver.java:102)

                                  ...

                               

                              here's my curl command and output:

                               

                              ****:~> curl -v --data-binary @tableau_datasource -H 'X-Tableau-Auth: [...]' -H 'Content-Type: multipart/mixed; boundary=Boundary:250323213dfa436cbf5857f38a1892bc' 'http://10.0.4.54/api/2.2/sites/[...]/datasources?overwrite=true'

                              *   Trying 10.0.4.54...

                              * Connected to 10.0.4.54 (10.0.4.54) port 80 (#0)

                              > POST /api/2.2/sites/[...]/datasources?overwrite=true HTTP/1.1

                              > Host: 10.0.4.54

                              > User-Agent: curl/7.43.0

                              > Accept: */*

                              > X-Tableau-Auth: [...]

                              > Content-Type: multipart/mixed; boundary=Boundary:250323213dfa436cbf5857f38a1892bc

                              > Content-Length: 450

                              >

                              * upload completely sent off: 450 out of 450 bytes

                              < HTTP/1.1 500 Internal Server Error

                              < Date: Wed, 31 Aug 2016 22:08:44 GMT

                              < Server: Tableau

                              < Content-Type: application/xml

                              < P3P: CP="NON"

                              < X-UA-Compatible: IE=Edge

                              < Connection: close

                              < Transfer-Encoding: chunked

                              <

                              * Closing connection 0

                              <?xml version='1.0' encoding='UTF-8'?><tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.1.2.xsd"><error code="500000"><summary>Internal Server Error</summary><detail>The server encountered an error and cannot complete your request. Contact your server administrator.</detail></error></tsResponse>

                               

                              and here's the tableau_datasource file. it's exactly 450 bytes, which matches the Content-Length request header.

                               

                              --Boundary:250323213dfa436cbf5857f38a1892bc

                              Content-Disposition: name="request_payload"

                              Content-Type: text/xml

                               

                              <tsRequest>

                                <datasource name="setup">

                                  <project id="ff35b546-7a21-4b61-9630-94e69318ca4f" />

                                </datasource>

                              </tsRequest>

                               

                              --Boundary:250323213dfa436cbf5857f38a1892bc

                              Content-Disposition: name="tableau_datasource"; filename="setup.tde"

                              Content-Type: application/octet-stream

                               

                              asdfqwert

                               

                              --Boundary:250323213dfa436cbf5857f38a1892bc--

                               

                              (yes, the "asdfqwert" file contents for setup.tde aren't a real TDE file, but this is just for testing, to make it easier to see. i get the same thing with a real full TDE file.)

                              • 12. Re: Internal Server Error With Publish Datasource Method
                                Ryan B

                                more progress. it seems like the server is actually trying to parse and load the TDE inline, inside the MIME multipart decoder and handler. so, i created a complete request body manually, with a valid TDE file. that got me a bit farther: i got an HTTP 100 response with a We are completely uploaded and fine message, and then an HTTP 502 error. :/

                                 

                                curl -v --data-binary @foo_datasource -H 'X-Tableau-Auth: [...]' -H 'Content-Type: multipart/mixed; boundary=250323213dfa436cbf5857f38a1892bc' 'https://10az.online.tableau.com/api/2.3/sites/[...]/datasources?overwrite=true'

                                *  Trying 66.35.252.163...

                                * Connected to 10az.online.tableau.com (66.35.252.163) port 443 (#0)

                                * TLS 1.2 connection using TLS_RSA_WITH_AES_256_GCM_SHA384

                                * Server certificate: online.tableau.com

                                * Server certificate: thawte SHA256 SSL CA

                                * Server certificate: thawte Primary Root CA - G3

                                > POST /api/2.3/sites/[...]/datasources?overwrite=true HTTP/1.1

                                > Host: 10az.online.tableau.com

                                > User-Agent: curl/7.43.0

                                > Accept: */*

                                > X-Tableau-Auth: [...]

                                > Content-Type: multipart/mixed; boundary=250323213dfa436cbf5857f38a1892bc

                                > Content-Length: 4855161

                                > Expect: 100-continue

                                >

                                < HTTP/1.1 100 Continue

                                * We are completely uploaded and fine

                                < HTTP/1.1 502 Bad Gateway

                                < Date: Wed, 31 Aug 2016 23:14:49 GMT

                                < Server: Tableau

                                < Content-Length: 257

                                < Content-Type: text/html; charset=iso-8859-1

                                <

                                * Connection #0 to host 10az.online.tableau.com left intact

                                <html><head><style type='text/css'>html, body, iframe {margin: 0px; padding: 0px; border: none;}</style></head><body><iframe src ='/errors/5xx.html' width='100%' height='100%' frameborder='0' marginheight='0' marginwidth='0' scrolling='auto'/></body></html>

                                • 13. Re: Internal Server Error With Publish Datasource Method
                                  Ryan B

                                  Tableau Server log now shows this exception, which i expect is the root cause of the HTTP 502 error:

                                   

                                  org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: Header section has more than 10240 bytes (maybe it is not properly terminated)

                                  ...

                                  Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Header section has more than 10240 bytes (maybe it is not properly terminated)

                                  ...

                                  • 14. Re: Internal Server Error With Publish Datasource Method
                                    Patrick Abernathy

                                    Morning Ryan.  Glad to see you got going on this.  I actually got that weird 10240 error as well.  This was caused by, no kidding, the spacing between the boundaries.  It looks like you're good by eyeballing your snippet above on the body of the request, but I'd check how you're actually building it.  You'll notice in my snippet that I'm using \r\n, this was due to .Net converting a \n into a \r\n automagically, but then it would cause my content length to be wrong therefor causing an overflow issue.  I don't know much about Python, but it might be worth looking into what you're using to create your carriage returns in your body.

                                    1 2 Previous Next