It’s not a good idea to send that long query with GET request. Even if you are able to change puma settings to allow that you still shouldn’t do it. Every browser and server (nginx etc) has its own limit and you will not pass it. POST request don’t have this limitation so you should use it.
If you get exactly the same error with POST request then you still trying to pass data through QUERY string rather than really send it as POST payload. Could you please paste code of this AJAX you send?
Hm, it looks ok. Please, have a look on that problematic request in chrome (or other browser you use) dev tool. You should see exactly how browser send request (chosen method, request url, payload etc). Maybe that request is not send by the code you pasted here. Anyway, error clearly indicated that the problem is that query string (it’s the part after ‘?’ in url) is too long.
Yes.I will pass around 300 parameters with comma separated.that is the reason I am getting this error.But Webrix server it is working fine.Since Webrix is slow and not supporting Concurrency,we have moved to puma.
It should work as json as well as form data. Your code looks good already. TBH I don’t know what the problem is. Maybe you could prepare working example of your problem? Try to isolate entire code (html, js + simple app running on puma) and create github repo which I can clone and try to run? Without having reproducible example I can’t help.
Oh, now I noticed you didn’t specify contentType header in your request (dataType sets expected response from browser, it has nothing to do with how you send data). Also you have to convert your data (javascript object) to json format.
I am able to post request with insert huge data into db.But I am getting below error if i am trying to POST in webservice call.
“Curl::Err::ConnectionFailedError”
def get_object
result_hash=Hash.new
result_hash["pa"]=false
result = ''
begin
if params['protocol']['pa'] == "true"
result_hash["pa"]=true
client=ClientCall.new
@macAddress= params['mac']
@model=params['parameter']
if @model.to_s.first ==","
@model = @model[1..-1]
end
total_params = 1
if @dataModel.include? (",")
paramArray = @model.split(/\s*,\s*/)
p "After Conversion"
p paramArray
total_params = paramArray.length
end
if total_params==1
if @macAddress.nil?
redirect_to root_path
elsif @model.nil?
redirect_to root_path
end
response=client.get_call(@macAddress, @dataModel)
redis_client=Redis.new
access_token=redis_client["Pa:SATToken"]
response_time = client.response_time
p "RESPONSE_TIME = #{response_time}"
p "Encoding = #{response.body.encoding}"
response.body.force_encoding('ISO-8859-1').encode("UTF-8")
p response.body
if access_token.nil?
sat_client=SatClient.new
response = sat_client.get_sat_token
body=JSON.parse(response.body)
if response.code == "200"
access_token=body["access_token"]
p "Storing Token in Redis"
redis_client=Redis.new
redis_client["Pa:SATToken"]=access_token
return access_token
else
p "SAT endpoint returned #{response.code}"
p "#{response.body}"
raise "Retrieving SAT Token call failed"
end
end
result_hash["response"]={"status": response.code,"parameter_name": @model.to_s, "body": response.body ,"accesstoken": access_token, "response_time": response_time.to_s};
else
result_hash["response"]={"status": "520", "body": "" };
end