Reputation: 4549
I am trying to consume REST service via ajax. For that I am sending jquery AJAX POST request which is failing with following message.
{"statusCode":400,"error":"Bad Request","message":"Payload content length greater than maximum allowed: 1048576"}
Payload size that we are trying to send is around 3 mb.
Service API is developed in JAVA and at service API side we have nginx as Web server and tomcat as application server.
How can I increase payload content length so that we can have resolution to above error?
AJAX is as below:
$.ajax({
type: "POST",
crossDomain: true,
//contentType: "application/json; charset=utf-8",
beforeSend: function (request) {
// Headers as below
setRequestHeadersOfFMAPI(request);
},
contentType: "application/json",
dataType: "json",
timeout: (3000 * 60 * 10),
url: urlContext + "/api/v1/application/google_bps_app/metrics/actuals",
data: JSON.stringify({
"actuals": activities
}),
success: function (data) {
}
);
Upvotes: 0
Views: 2191
Reputation: 6276
For increasing the packet size you don't need to do anything on Java side but you need to change the nginx configuration on server.
You need to increase the size (which might be set in configuration, if not add it) for the parameter, client_max_body_size
.
Remember This parameter takes size in bytes, so calculate and put the number as high as your packet max size may be.
Upvotes: 0
Reputation: 32354
Edit Tomcat's server.xml
. In the <Connector>
element, add an attribute maxPostSize
and set a larger value (in bytes) to increase the limit.
Upvotes: 1