AngularJS $resource - 414 Request-URI Too Large
-
21-12-2019 - |
Question
I use AngularJS $resource to save large objects. Everything worked good, until object became really large.
angular.module('Test.services').factory('TestService', function($resource) {
return $resource( '/MyRestURL/:id', { id: "@id" }, {
save : {
method: 'POST',
isArray: false,
params: {
data: "@data"
}
}
});
});
I get response
Method POST
Cached No
Status Request-URI Too Large
Code 414
And I see it sends everything in URL...
Solution
Try using
angular.module('Test.services').factory('TestService', function($resource) {
return $resource( '/MyRestURL/:id', { id: "@id" }, {
save : {
method: 'POST'
}
});
The params
tell angular to put that property in the url as get parameter. (And the isArray
is false by default.)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow