HTTP 413 with a 1.29KB POST?

I have an Http In node which fails to accept a 1.29KB POST resulting with this error:

PayloadTooLargeError: too many parameters
at queryparse (/usr/src/node-red/node_modules/body-parser/lib/types/urlencoded.js:151:13)
at parse (/usr/src/node-red/node_modules/body-parser/lib/types/urlencoded.js:75:9)
at /usr/src/node-red/node_modules/body-parser/lib/read.js:121:18
at invokeCallback (/usr/src/node-red/node_modules/raw-body/index.js:224:16)
at done (/usr/src/node-red/node_modules/raw-body/index.js:213:7)
at IncomingMessage.onEnd (/usr/src/node-red/node_modules/raw-body/index.js:273:7)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

It' 1.0.4, but it used to work with pre-1.0 versions, so I'm stumped :slight_smile:

This means you are sending over 1000 parameters as part of the post request - which does seem quite excessive.

Between pre-1.0 and 1.0 we would have upgraded the various modules that handle the incoming requests. I can only assume something in there has changed its behaviour in this area.

The module in question does allow this limit to be changed - but we don't expose it in any meaningful way: body-parser/README.md at master · expressjs/body-parser · GitHub

Are you able to change it to send them as the body of the POST rather than query params?

The post is made like this:

    $.ajax({
            url: url,
            type: "POST",
            dataType: "json",
            data: {
	    action: "upload",
	    data: some_array,
	    year: year,
	    month: month,
	    day: day,
	    uid: uid,
	    gid: gid,
	    sid: sid
            },
	success: function(data, textStatus, jqXHR) {
	    alert("OK");
	}});

At some point you may have to read the jquery api docs for yourself to figure this out...

Maybe try:

$.ajax({
            url: url,
            type: "POST",
            dataType: "json",
            data: JSON.stringify({
  	    action: "upload",
	    data: some_array,
	    year: year,
	    month: month,
	    day: day,
	    uid: uid,
	    gid: gid,
	    sid: sid
            }),
	success: function(data, textStatus, jqXHR) {
	    alert("OK");
	}});

Well from https://api.jquery.com/jQuery.ajax/ "data" can be a "PlainObject"
And it works now with first "data" as an object and second data = JSON.stringify(some_array)

Or, from the same page, you could add:

contentType: "application/json"

which tells it to send the data as JSON encoded data in the body, rather than its default behaviour of encoding as query params.

Well I'm pretty sure it used to work like this :slight_smile:... Pre-1.0.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.