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.
The possible reason behind this is the data type used for
usedId
.For
int
, the range is until2,147,483,647
try changing the data type tolong
which has range until9,223,372,036,854,775,807