Getting ActionDispatch::ParamsParser::ParseError (822: unexpected token at parameters)


#1

I am getting below error while passing huge query string in AJAX Post request.I am using Puma Server.How to fix this issue in puma server?

HTTP parse error, malformed request ():<Puma::HttpParserError: HTTP element 
 QUERY_STRING is longer than the (1024 * 10) allowed length (was 13692)>

Or Is there any app server available to support Concurrency and long url?


#2

what is the client doing/using to post the request?


#3

I was using GET request before.Now I am using POST and getting below error.
ActionDispatch::ParamsParser::ParseError (822: unexpected token at parameters)
My Ajax code

if (Device1) {
  parameter_name = $('#parameters_object').val();
  var getParams=parameter_name.split(',');
  paramLen=getParams.length;
  alert(paramLen);
  if (paramLen > 200){

  }

  //m is a selected mac address length count
  for (var i = 0; i < m; i++) {

    (function () {

      var macAdd = values[i];
      $.ajax({
          method: "POST",
          url: "get_object",
          dataType: "json",
          data: {
            parameter: getParams,
            mac: macAdd,
            protocol: protocol,
            serialnumber: serialnumber,
          },

          success: function (result) {
            console.log(result);

          }
        },

        statusCode: {
        404: function () {
          console.log("Call failed");
        }
      }
    });

  })();

}

#4

try adding the processData property to the ajax call options, set to false.

$.ajax({
    ...
    processData: false,
    data: { ... }
   ...
});

edit:

that may not work, are there any non alpha characters in getParams?
if so, you can try

parameter: getParams.map(function(param) { return encodeURI(param); }),

edit2:

if handler is expecting request body of json

data: JSON.stringify({
    parameter: ...,
    ...
 }),

#5

Yes Thanks.JSON.stringify working fine.