I am using Spring MVC 4. Here is my controller code:
@RestController
public class NewValueController
{
@RequestMapping(value="/receiveUpdatedScore",method=RequestMethod.POST,produces={"application/json"})
public NewValue receiveUpdateScore(@RequestParam(value="score") short score,
@RequestParam(value="user_id") String user_id,
@RequestParam(value="device_model") String device_model,
@RequestParam(value="api_key") String api_key,
@RequestParam(value="gen_t") long gen_t,
Model model)
{
int newScore = (int) score;
NewValue algorithm=new NewValue();
NewValue newvalue=algorithm.getNextValue(newScore);
return newvalue;
}
}
I am making this Request using Advanced rest client(also tried same in Postman):
{"score":"50","user_id":"zyz","device_model":"xiami","api_key":"sasa5454","gen_t":"545666"}
But I am getting following error
Error:
HTTP Status 400 - Required Short parameter 'score' is not present
message: Required Short parameter 'score' is not present
description: The request sent by the client was syntactically incorrect.
What is the mistake I am not able to detect here. Please help me to resolve it.
I think this is because score is expected as part of the url and not some JSON that you post