Setting up an Java Postman call assigning values to the variables but its shows null.
@PostMapping("/caStudents/student") public String generateSignedValue(@RequestBody StudentRequest studentRequest) throws Exception String signedValue=studentService.getSignedValue(studentRequest); return signedValue;
My Pojo Student
Class
public class StudentRequest { String user; Long duration ; public String getPublicKey() { return publicKey; } public void setPublicKey(String publicKey) { this.publicKey = publicKey; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public Long getDuration() { return duration; } public void setDuration(Long duration) { this.duration = duration; }
Postman Request
{"studentRequest":[{"user":"admin","duration":19336}]}
Advertisement
Answer
your request body should be like this:
{"user":"admin","duration":19336}
because you are getting StudentRequest
as RequestBody
and it means you should send StudentRequest
internal properties not containing StudentRequest
it self in request ,
second problem is that your RequestBody
contains singular object not array .