Reputation: 177
this is my angularjs code
$scope.createOrderObject.orderItemObjs=JSON.stringify($scope.createOrderObject.orderItemObjs);
$scope.createOrderObject
is an array, this contain more than 3 array. when i add upto 5 products this is working super fine but when i try to add 6th item it showing 400 error.
$http({
method: "POST",
url: baseUrl + "/Order/saveOrUpdateOrders",
params: $scope.createOrderObject,
headers: {
'Content-Type': 'application/json',
}
Post url is becoming very big about 5000 char after that browser telling this request as malform url.
i receive this request in servlet like this
@RequestMapping(value = "/Order/saveOrUpdateOrders", method =RequestMethod.POST)
public void saveOrUpdateOrders(OrdersFormObj orderFormObj, HttpServletResponse response, HttpServletRequest request) throws IOException {
try {
String addCity = request.getParameter("addCity");
String addDist = request.getParameter("addDist");
String orderItemObjs = request.getParameter("orderItemObjs");
this is one is
String orderItemObjs = request.getParameter("orderItemObjs");
Stringfy array
Really i dont know what is the problem. i suspect url length but i dont know how to fix this. please help to get rid off this
Upvotes: 0
Views: 626
Reputation: 2119
This seems to be a problem with length of your params in POST request. Do read below
What is the maximum length of a URL in different browsers?
So, I would say you use some other mechanism to send your data to server.
Instead of params
, you should use data
like below
$http({
method: "POST",
url: baseUrl + "/Order/saveOrUpdateOrders",
data: $scope.createOrderObject,
headers : {
'Content-Type' : 'application/json'
})
Upvotes: 1
Reputation: 1859
Try to make ajax call in this way :
var req = {
method: 'POST',
url: baseUrl + "/Order/saveOrUpdateOrders",
headers: {
'Content-Type': "application/json"
},
data: $scope.createOrderObject
}
$http(req).success(function(){...}).error(function(){...});
"params" is for GET call, use "data" with post call
Upvotes: 1
Reputation: 13
POST method doesn't have any size limit. However, the server you might be using to run your application on, may have some size restriction. You might want to check that. Check this for reference: AngularJs $http.post() request is not sending when sending data size is huge?
The other option is to go with Pagination of data and send in small chunks.
Upvotes: 0