Tableau-Powershell-Scripts icon indicating copy to clipboard operation
Tableau-Powershell-Scripts copied to clipboard

Unable to publish Data Source. :- Exception calling "UploadString" with "3" argument(s): "The remote server returned an error: (502) Bad Gateway."

Open nlian opened this issue 6 years ago • 10 comments

Hi Glen,

Do you have an example of publishing a .hyper file, how should I call the TS-PublishDataSource ? I got the following error when publishing .hyper on 2018.3

Unable to publish Data Source. Sample :- Exception calling "UploadString" with "3" argument(s): "The remote server returned an error: (502) Bad Gateway."

Here what I use:

TS-Signin -server $server -username $username -password $password -protocol https -siteID $SiteID

 $RetStatus = TS-PublishDataSource -ProjectName Testing -DataSourceName Sample -DataSourceFile Sample.hyper -DataSourcePath C:\Batch\Input -UserAccount user -Password Pwd -Embed False -oAuth False -OverWrite False

TS-Signout

Thanks,

Lian

nlian avatar Aug 02 '19 06:08 nlian

Hi Lian,

I believe you’ll need to publish a .tds or .tdsx that points to or includes the hyper file.

tonykau1 avatar Aug 02 '19 06:08 tonykau1

Near as I can tell you can publish a hyper file if you open it in Tableau Desktop first, generate an extract from it, and publish the hyper file that extract generates instead.

What this does under the sheets is moves the data into the extract schema, which appears to be where Tableau wants it. Unfortunately that makes the hyper API less useful. If someone figures out a better way please do tell!

JBandy avatar Aug 07 '19 00:08 JBandy

Hello Glen, I am trying to use the TS-PublishWorkbook function and I am getting this error:

PS C:> TS-PublishWorkbook -ProjectName "REST API" -WorkbookName "Prueba RestAPI" -WorkbookFile dashy.twbx -WorkbookPath C:\testy

Unable to publish workbook. Prueba RestAPI :- Exception calling "UploadString" with "3" argument(s): "The remote server returned an error: (400) Bad Request."

Any help?

hectorlavalle avatar Oct 27 '20 16:10 hectorlavalle

Hi Hector, If you are able to access the vizportal logs on the server, they give a better indication as to the issue. Otherwise, it is going to be a trial and error to find out the issue. Does the workbook use a Published Data Source, and if so is this on the site? Is the TWBX correct, ie its not a TWB? Do you have permission to publish to this site / project? What size is the of the TWBX? Is there any other information you can give me? Thanks Glen

glenrobinson72 avatar Oct 27 '20 22:10 glenrobinson72

I have not accessed the vizportal logs, I managed to better use a python script. To answer your questions:

  • Yes the workbook uses a published data source
  • Yes it is a twbx
  • I am logging in to Tableau Server as Tableau Server Administrator so I have full access
  • It is a very small twbx no more than 1 MB

hectorlavalle avatar Nov 04 '20 20:11 hectorlavalle

Did any y'all figure this out?

I'm getting the same error, but when trying to publish a .twb.

The TS-Signin works successfully:

API Version: 3.6 Tableau Version: 20194.19.1211.1636

But, when attempting to publish a workbook:

TS-PublishWorkbook -ProjectName "Default" -WorkbookName "fuel.XXX.Sample" -WorkbookFile "fuel.XXX.Sample.twb" -WorkbookPath "C:\Users\david\Desktop\Work Time!\Workbooks\NG\Deploy" -OAuth True -OverWrite True -Chunked false

I get: Unable to publish workbook. fuel.XXX.Sample :- Exception calling "UploadString" with "3" argument(s): "The remote server returned an error: (400) Bad Request."

I've tried every combination I can think of.

DavidStachon avatar Mar 10 '21 23:03 DavidStachon

Hi David To troubleshoot the issues with publishing, can you try the followng. Are you able to publish a 'simple' TWBX workbook. say something like one of the samples workbooks? Also, do you have access to the vizportal logs on the server? this is the best place (i think) to find out what the issue is with publishing

glenrobinson72 avatar Mar 11 '21 23:03 glenrobinson72

Hi Glen, thx for the reply.

Same issue with the sample workbook.

(and, btw I tried commands like TS-CreateProject with no problem):

Here was the call: (I tried chunked and as backgroundtask as true as well with same result)

TS-PublishWorkbook -WorkbookName "World Indicators.twbx" -WorkbookFile "World Indicators.twbx" -WorkbookPath "C:\temp\" -ProjectName "Sandbox"

and from the vizportal:

2021-03-12 19:59:44.801 +0000 (,,,,) catalina-exec-71 : ERROR com.tableausoftware.api.rest.util.RestApiControllerAdvice - 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) 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) at com.tableausoftware.api.rest.util.RestApiMultipartResolver.parseRequest(RestApiMultipartResolver.java:103) at org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:143) at com.tableausoftware.api.rest.util.RestApiMultipartResolver.resolveMultipart(RestApiMultipartResolver.java:66) at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1104) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:936) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at com.tableausoftware.web.utils.SafeRedirectFilter.doFilter(SafeRedirectFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.commons.fileupload.FileUploadException: Header section has more than 10240 bytes (maybe it is not properly terminated) at com.tableausoftware.api.rest.util.RestApiMultipartResolver$RestApiFileUpload.parseRequest(RestApiMultipartResolver.java:171) at com.tableausoftware.api.rest.util.RestApiMultipartResolver$RestApiFileUpload.parseRequest(RestApiMultipartResolver.java:132) at com.tableausoftware.api.rest.util.RestApiMultipartResolver.parseRequest(RestApiMultipartResolver.java:98) ... 37 more Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Header section has more than 10240 bytes (maybe it is not properly terminated) at org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:574) at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:1052) at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.hasNext(FileUploadBase.java:1121) at com.tableausoftware.api.rest.util.RestApiMultipartResolver$RestApiFileUpload.parseRequest(RestApiMultipartResolver.java:146) ... 39 more

DavidStachon avatar Mar 12 '21 20:03 DavidStachon

HI Can you take a look a the code, and ensure that the ts-publishworkbook looks exactly like this, with not additional carriage returns or altered charactors. thanks

` $request_body = ' --6691a87289ac461bab2c945741f136e6 Content-Disposition: name="request_payload" Content-Type: text/xml

' + $Connection_Details + $viewsbody + ' --6691a87289ac461bab2c945741f136e6 Content-Disposition: name="tableau_workbook";filename="' + $WorkbookFile + '" Content-Type: application/octet-stream

' + $WB_Content + ' --6691a87289ac461bab2c945741f136e6--' `

glenrobinson72 avatar Mar 13 '21 08:03 glenrobinson72

OMG. Yes, that was it.

That's totally my fault for just doing a copy paste from github as opposed to properly downloading the ps1 file.

Thank you so much, and sorry for such a noob question.

DavidStachon avatar Mar 13 '21 14:03 DavidStachon