AnsweredAssumed Answered

Calling a service to download a file does not handle the response, but the service is actually called and returns an http 200

Question asked by mhylden on May 11, 2016
Latest reply on May 12, 2016 by mhylden

I have built a web service running locally that will send an excel file back as part of the request.  If I put the URL directly in a browser, I get the file as an attachment as expected. 

http://localhost:6993/api/ExportFile/?inString=urlString&jsonData=urlData

 

I am trying to call this from a button click that I have added to a customized attribute table.  At this point, I'm not passing 'real' data but simply trying to get the test file to be downloaded in the WAB app.  If I'm running the service in debug, I do hit the breakpoint in the service with the values passed in the following esri.request call.  Fiddler indicates that the call sends back a 200 status, so the service seems to be ok.  The problem is that it seems to die in the esri request side - neither my success nor failure gets handled by the javascript. 

 

Any ideas on what I need to change in the ESRI Request call would be greatly appreciated.  Note that if I do the export to CSV that is built in to the attribute table that has no problem streaming a file as an attachment. 

 

          var exportURL = this.config.exporttoexcelservice;

          var list = esriRequest( 

            { 

                url: exportURL,

                //content: { f: "json", "jsonData": this.getCurrentTable() },

                content: { f: "json", "inString": "New Data Value", "jsonData": this.getCurrentTable().grid },

                handleAs: "blob",

                callbackParamName: "callback", 

                timeOut:20000, 

            });

 

 

          list.then( 

            //lang.hitch(this,

                function (response) {

                    console.log("Success from Export: ", response);

                }, 

                function(error) { 

                    console.log("Failure on Export: ", error.message);

                }//) 

          );

Outcomes