Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    downloadResult and POST data

    Hi,

    Using SmartClient_v90p_2014-01-24_Pro (Google Chrome), I'm having an issue with DSRequest.downloadResult and POST data.

    We want to fetch server to generate an excel file. We have to use a POST because we need to include a picture in the excel which is generated from a SVG that we give in the request payload.

    So I use the following code

    Code:
    var svg = 'SVG to send';
    
    RPCManager.sendRequest({
    	actionURL : url,
    	httpMethod : 'POST',
    	contentType : 'text/html',
    	exportDisplay : 'window',
    	downloadResult : true,
    	downloadToNewWindow : true,
    	httpHeaders : { 'Accept' : 'application/vnd.ms-excel' },
    	showPrompt : false,
    	data : svg
    });
    The problem is that the payload is wrapped in a transaction when I put downloadResult to true.

    The payload I catch with Fiddler is something like the following (after some transformation to be easier to read)
    Code:
    _transaction=
    <transaction+xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"+xsi:type="xsd:Object">
    <transactionNum+xsi:type="xsd:long">29</transactionNum>
    <operations+xsi:type="xsd:List">
    <elem>My SVG</elem>
    </operations>
    <jscallback>if+%28%21%28new+RegExp%28&quot;%5E%28%5C%5Cd%7B1%2C3%7D%5C%5C.%29%7B3%7D%5C%5Cd%7B1%2C3%7D%24&quot;%29.test%28document.domain%29%29%29+%7Bwhile+%28%21window.isc+&amp;&amp;+document.domain.indexOf%28&quot;.&quot;%29+%21=+-1+%29+%7B+try+%7B+parent.isc;+break;%7D+catch+%28e%29+%7Bdocument.domain+=+document.domain.replace%28/.*%3F%5C./%2C+&quot;&quot;%29;%7D%7D%7Dparent.isc.Comm.hiddenFrameReply%2829%2Cresults%29</jscallback>
    </transaction>
    &protocolVersion=1.0&__iframeTarget__=request_1399900588089
    In the backend I'm waiting for a String which contains the SVG I have to work with, but I get an empty params.

    When downloadResult is false the payload contains only the data and my param is valued so I can use it.

    Any idea to get a payload which contains only the SVG we want to send and don't data wrapped in a transaction?

    Thanks for your help

    #2
    See the Upload / Download folder for sample code for doing this. You didn't post server-code but you are probably missing the call to doCustomResponse at least.

    Comment


      #3
      I don't post server-code because we don't use it. I forgot to put useSimpleHttp : true in the front-end I've posted.

      I just wanted to call my backend (which is not SC) and download the result as a file, that's why I use the param downloadResult.

      But when my payload is serialized, it's wrapped in a <transaction> element so the backend is not able to deserialize it because it doesn't this element <transaction>...

      Any idea to get rid of this wrapper?

      PS : The backend return an Excel file, and put these headers to the HTTP response
      Content-type : "application/vnd.ms-excel"
      Content-disposition : "attachment;filename=myfile.xlsx"
      Last edited by gdeimat; 14 May 2014, 07:27. Reason: Add informations

      Comment


        #4
        Please remember to mention in the future that you are not using the server framework - that's kind of important to know.

        The <transaction> wrapper is part of the protocol used to contact the server framework. useSimpleHttp:true does get rid of it (you seem to say it doesn't, but it does).

        Note that "exportDisplay" does not make any sense to set here.

        Comment


          #5
          OK, sorry to forget mention that.

          As I say, I putted useSimpleHttp to true and I still have the <transaction> wrapper.

          I don't know if it's in relation but I can observe the following behaviour when I ran RPCManager.sendRequest() in debug :
          If downloadResult = false, request.transport = xmlHttpRequest.
          But if downloadResult = true, request.transport is enforced to hidden.

          Comment


            #6
            The downloadResult property is also a property that makes sense to use only with the SC Server (and the hiddenFrame protocol only works with the SC Server).

            Comment


              #7
              Is this still relevant? I'm using SmartClient 13 (v13.0p_2023-08-01/LGPL Deployment) in combination with RubyOnRails back-end. I'm trying to retrieve a PDF file using this code:

              Code:
              isc.RPCManager.sendRequest({
                actionURL: `file.pdf`,
                downloadResult: true,
                httpMethod: 'GET',
                useSimpleHttp: true
              });
              The file seems to be returned in the response, but the development console shows:

              Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.

              Comment


                #8
                As covered above, downloadResult is a property that is used with the SmartClient Server, which you are not using. So it does not apply to you.

                Presumably, you were hoping for something specific to happen.. please start a new thread explaining what you wanted to happen, and we can then help you to do it.

                Comment


                  #9
                  Okay, I will do that. Thanks for the reply.

                  Comment


                    #10
                    Originally posted by Isomorphic View Post
                    As covered above, downloadResult is a property that is used with the SmartClient Server, which you are not using. So it does not apply to you.

                    Presumably, you were hoping for something specific to happen.. please start a new thread explaining what you wanted to happen, and we can then help you to do it.
                    Perhaps it's a good idea to mention that in the docs of the "downloadResult" property in RPCRequest.

                    Comment


                      #11
                      Hi Wally, please see the docs for rpcRequest.useSimpleHttp. Those docs cover the properties that are valid with that mode.

                      Comment

                      Working...
                      X