1

I am trying to send an JSON object to my webservice which is expecting JSON in the request data. This my POST call from angularJS

$http({method: 'POST',
        url: 'update.htm',
        data: $.param($scope.cover),
        headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
    }).success(function (data) {
    // handle
    });

Value for cover object

$scope.cover = {id:1, bean:{id:2}}

Iam getting 500 (InvalidPropertyException: Invalid property 'bean[id]' of bean class [BookBean]: Property referenced in indexed property path 'bean[id]' is neither an array nor a List nor a Map;)
In network, it is sending in this way

bean[id]:1

I think it should send like

bean.id:1

How to reslove this issue. Thanks in advance

vivek
  • 4,599
  • 3
  • 25
  • 37

2 Answers2

0

Looks like the data is getting to the server and is causing an error there. There's a possible duplicate question that's been answered here - Post Nested Object to Spring MVC controller using JSON

Community
  • 1
  • 1
Jason Watmore
  • 4,521
  • 2
  • 32
  • 36
0

Try posting your data like:

$http({method: 'POST',
        url: 'update.htm',
        data: $scope.cover,
    }).success(function (data) {
    // handle
    });
BKM
  • 6,949
  • 7
  • 30
  • 45