I'm having a controller which gets json as string in request body as below
@PostMapping("/addUser")
public ResponseEntity<?> addUser (@RequestBody String userJson,HttpServletRequest request) {
log.info("inside add user controller")
String responseStatus = serviceInterface.addUser (userJson);
return new ResponseEntity (responseStatus);
}
The request body is
{
"user": {
"username": "testuser",
"userId": 12345678901233,
"phonenumber": "9876756475",
"emailaddress": "[email protected]"
}
}
The problem i'm facing is when the userId property has more than 10 digits the controller returns 404 error the request won't even reach the controller , but if i reduce the the number of digits to less than 10 say 123456789, i'm getting the actual expected response . The reason i'm keeping the request body as String because sometimes the request maybe a graphql String or a JSON String but this occurs for both scenarios.
It might be because of the range for an Integer in java which is the type of userId field.
The range of an int in java is -2,147,483,648 .. 2,147,483,647.
So try inside and outside this range and check if it works for the range and doesn't work for out of range then that's the issue.
In that case you will have to change int to long data type.