4 Replies Latest reply on Feb 17, 2016 8:42 AM by Peter Jones

    REST API Publish Datasource

    Peter Jones

      Before I reinvent the wheel here is there a C#.NET Example using WebClient http for doing this?

        • 1. Re: REST API Publish Datasource
          Tharashasank Davuluru

          Hi Peter jones,

           

          please have a look at this thread it might help you REST API using C#

          1 of 2 people found this helpful
          • 2. Re: REST API Publish Datasource
            Peter Jones

            Yes that's a good example of an XML request but I need to publish a datasource back to the server after adding user filters via and SDK process.

             

            The instructions for the message use a mulitpart mime message with the 2nd portion being the datastream of byte[] of the datasource file.  In this example you're just sending an xml request message, I'm doing that now in several other calls.

             

            Thank you for the response but this doesn't really answer it, so I will post a working solution to this when I get one working myself.

            • 3. Re: REST API Publish Datasource
              Peter Jones

              So here's a sample of my request (RAW) picked up from fiddler for the Publish, this request gets a 502 Bad Gateway error from the Tableau server?

               

              Any idea why that would be happening?

               

              Request Raw Data:

              POST http://<MyHostIP>/api/2.1/sites/3f99e39c-105b-4dcc-93c9-f337503526a2/datasources?overwrite=true

              X-Tableau-Auth: wfwMbQ1S0306XxK6a3Y4r1L4kfmHdDM5

              Content-Type: Content-type: multipart/mixed; boundary=*****--Boundary--3c920e38-c4fc-4947-9b6d-cffa26cf32bb*****

              Host: <MyHostIP>

              Content-Length: 10370799

              Expect: 100-continue

               

               

              *****--Boundary--3c920e38-c4fc-4947-9b6d-cffa26cf32bb*****

              Content-Disposition: name="request_payload"

              Content-Type: text/xml

               

              <tsRequest><datasource name=StandardExtract_CID_BQ><project id="8b50dfd0-03bb-49ea-bca3-9fb835c30c81" /></datasource></tsRequest>

              *****--Boundary--3c920e38-c4fc-4947-9b6d-cffa26cf32bb*****

              Content-Disposition: name="StandardExtract_CID_BQ"; filename="StandardExtract_CID_BQ.tds"

              Content-Type: application/octet-stream

               

              <binary data stream>

              *****--Boundary--3c920e38-c4fc-4947-9b6d-cffa26cf32bb*****

              • 4. Re: REST API Publish Datasource
                Peter Jones

                Well I seemed to have found my own error here.  In the below <snip> of the headers I had repeated "Content-Type: " twice.  Once this was fixed, I get a different error 500 Internal server error (which I think is something internal here causing that) so I believe this issue is resolved for the time being.

                 

                Raw request header content:

                POST http://<MyHostIP>/api/2.1/sites/3f99e39c-105b-4dcc-93c9-f337503526a2/datasources?overwrite=true

                X-Tableau-Auth: wfwMbQ1S0306XxK6a3Y4r1L4kfmHdDM5

                Content-Type: Content-type: multipart/mixed; boundary=*****--Boundary--3c920e38-c4fc-4947-9b6d-cffa26cf32bb*****

                1 of 1 people found this helpful