Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Variables are not coming up null during Postman call

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{"studentRequest":[{"user":"admin","duration":19336}]}

>Solution :

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 .

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading