PayloadTooLargeError



  • I am getting the following error:

    2017-12-07T10:18:44.956Z - error: Error during processing request: http://localhost:5488/api/report details: too many parameters PayloadTooLargeError: too many parameters
        at queryparse (C:\0\programming\0projects\jsServer2\node_modules\body-parser\lib\types\urlencoded.js:150:13)
        at parse (C:\0\programming\0projects\jsServer2\node_modules\body-parser\lib\types\urlencoded.js:75:9)
        at C:\0\programming\0projects\jsServer2\node_modules\body-parser\lib\read.js:116:18
        at invokeCallback (C:\0\programming\0projects\jsServer2\node_modules\raw-body\index.js:262:16)
        at done (C:\0\programming\0projects\jsServer2\node_modules\raw-body\index.js:251:7)
        at IncomingMessage.onEnd (C:\0\programming\0projects\jsServer2\node_modules\raw-body\index.js:307:7)
        at emitNone (events.js:105:13)
        at IncomingMessage.emit (events.js:207:7)
        at endReadableNT (_stream_readable.js:1056:12)
        at _combinedTickCallback (internal/process/next_tick.js:138:11)
        at process._tickCallback (internal/process/next_tick.js:180:9)
    

    I am creating a report that dynamically creates the headers and rows. This is the template:

    <table cellpadding="5" cellspacing="5">
        <tr>
            {{#each columnHeaders}}
            <td>{{name}}</td>
            {{/each}}
        </tr>
        {{#each rows}}
        <tr>
            {{#each columnValues}}
            <td>{{value}}</td>
            {{/each}}
        </tr>
        {{/each}}
    </table>
    

    The recipe is html and the engine is handlebars.

    In my angular client app I am dynamically creating the data. This is my code:

    toReport(){
        this.reportData.columnHeaders = new Array();
        this.reportData.rows = new Array();
        console.log("toReport reportData:", this.reportData);
        let that = this;
        this.data.forEach(function(item, index){
          let len = item.length;
          if(index === 0){ //headers
            item.forEach(function(item2, index){
              let colh = new ColumnHeader(item2);
              that.reportData.columnHeaders.push(colh);
            })
          }
          else{
            let row = new Row();
            row.columnValues = new Array();
            item.forEach(function(item2, index){
              //console.log("values", item2, index);
              let colv = new ColumnValue(item2);
              row.columnValues.push(colv);
            })
            that.reportData.rows.push(row);
          }
        });
        console.log("reportdata:", this.reportData);
        let url = "http://localhost:5488/api/report"//"https://frail.jsreportonline.net/api/report";
        var request ={
          "template": { "shortid" : "HyBItB4Zf" },
          "data": this.reportData,
          "contentType": "application/json"
        }
        this.jsr.serverUrl = "http://localhost:5488" //"https://frail.jsreportonline.net";
    
        this.jsr.headers['Content-Type'] = "application/json";
        this.jsr.render('_blank', request);
    
        // this.jsr.renderAsync(request).then(function(res) {
        //   var html = '<html>' +
        //     '<style>html,body {padding:0;margin:0;} iframe {width:100%;height:100%;border:0}</style>' +
        //     '<body>' +
        //     '<iframe src="' +  res.toDataURI() + '"></iframe>' +
        //     '</body></html>';
        //   var a = window.open("about:blank", "Report");
        //   a.document.write(html);
        // });
      }
    

    Using jsr.render works for 99 rows of data. If I use more data than that I get the "too many parameters PayloadTooLargeError".
    If I try jsr.renderAsync I get the following error:

    2017-12-07T10:53:02.107Z - error: Error during processing request: http://localhost:5488/api/report details: 
    Could not parse report template, aren't you missing content type? undefined
    

    As you can see above in my code I do set the contentType.
    Please help.


  • administrators

    hi! the jsreport browser sdk render function serializes the input data into urlencoded request (you don't need to change the content type), this can easily hit the size limits if the input data set is large (like in your case), have you tried to use the renderAsync function? renderAsync sends the data as json payload so it is more compact, you can also increase the inputRequestLimit in your jsreport configuration file and that can help too



  • Thanks bjrmatos for replying. I increased the inputRequestLimit to 80mb and still get the "too many paramaters" error. If I use async I get the following error:

    2017-12-07T16:49:02.244Z - error: Error during processing request: http://localhost:5488/api/report details: Could not parse report template, aren't you missing content type? undefined
    

  • administrators

    can you please post your updated code that uses renderAsync? for some reason your request is not being properly sent to jsreport, can you please also remove the headers and any reference to contentType, Content-Type? this is not necessary because renderAsync does that



  • Nice bjrmatos! Once I took out the content-type header the renderAsync worked. I am evaluating your product and it looks very good. It looks like you put a lot of thought into it. Is there a place where one could go for custom extensions?


  • administrators

    thanks. for custom extensions we have this section in our docs, it does not contain full details of more advanced cases for extensions (because documenting all is a hard task) but it gives a nice overview of how to write an extension. and of course you can also check our open source org which contains the repositories for all extensions behind the full jsreport, you will see that each feature of jsreport is implemented as an extension and you can easily inspect how each of them work by looking into the code in github.



  • Thanks!!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.