Kei
Kei

Reputation: 315

Java AngularJS Spring MVC - $http.post 400 bad request syntactically incorrect when sending bean to controller

I'm writing an application that would assume an admin that will create an Employee record with his/her particulars, and also assigning the newcomer with an existing "Team" as well as the skill sets corresponding to the roles/position that he/she has or require. Naturally That will have 4 different Objects to handle that. I've decided to use a bean to store the Employee Object, the Team Object, and the Skills and Roles Object.

The first bean will be to store the Skills and Roles, RoleNSkills. Each Rolecan require many Skills and an Employee can assume many Roles. Each Employee may only be assigned to one Team at a time. Hence the second bean will assume the list of RoleNSkills as well as the employee data and the team that he will be assigned to.

Note, team and group means the same thing in this context. We use team for front end purposes.

Error:

This are the object that Google Chrome returns me while I'm trying to figure out what is exactly which resource is causing me problems. I have previously added employee as a single resource and it worked so that will be ruled out.

JSON Formatter: http://www.freeformatter.com/json-formatter.html Heres the full JSON that I managed to get it out from the object that I'm dealing with:

AngularJS making the post

Update: Still nothing. I suspect that it's because of the CreatedAt and UpdatedAt under the RoleNSkills being in milliseconds and I'm trying to post those to the controller and it completely rejects me. But I'm trying to find where those were defined but to no avail. If anyone is willing to help me search I can post any requested resource for you to look at.

Update2: Maybe, since inside my Database, it is defined in this manner '2015-06-22 15:03:09', and when I issue a "get" to get all the skills and roles from the database, and it gives me in the format of milliseconds, I should do the same when I post?

Upvotes: 1

Views: 591

Answers (1)

KlajdPaja
KlajdPaja

Reputation: 959

The error you are getting is related to incorrect json being sent to the controller, most likely this would be fixed by using JSON.stringify(paramEmployee) which serializes a Javascript object into a string.

Upvotes: 2

Related Questions