title: Bad Request with 400 status code in Spring boot
body: <p>Recently I am using Spring boot framework with Kotlin. Every thing is all okey with GET method. But when registering a new user with POST method I go faced some problem having Bad Request with status code 400.
  Here is my code associate with my spring boot project</p>
  <p><code>User.kt</code></p>
  <pre><code>@Entity
  @Table(name = &quot;user_info&quot;)
  data class User(
      @Id
      @SequenceGenerator(
          name = &quot;user_seq&quot;,
          sequenceName = &quot;user_seq&quot;,
          allocationSize = 1
      )
      @GeneratedValue(
          strategy = SEQUENCE,
          generator = &quot;user_seq&quot;
      )
      @Column(
          name = &quot;id&quot;,
          updatable = false
      )
      val id: Long = -1,
  
      @Column(
          name = &quot;first_name&quot;,
          nullable = false,
          length = 50,
          updatable = true
      )
      val firstName: String,
  
      @Column(
          name = &quot;last_name&quot;,
          nullable = false,
          length = 50,
          updatable = true
      )
      val lastName: String,
  
      @Column(
          name = &quot;email&quot;,
          nullable = true,
          length = 150,
          updatable = true
      )
      val email: String,
  
      @Column(
          name = &quot;gender&quot;,
          nullable = false,
          length = 2,
          updatable = true
      )
      val gender: String,
  
      @Column(
          name = &quot;date_of_birth&quot;,
          nullable = false,
          updatable = true
      )
      val dateOfBirth: LocalDate,
  
      @Column(
          name = &quot;country&quot;,
          nullable = false,
          length = 50,
          updatable = true
      )
      val country: String
  )
  </code></pre>
  <p><code>UserController.kt</code></p>
  <pre><code>@RestController
  @RequestMapping(
      path = [
          &quot;/api/v1/&quot;
      ]
  )
  class UserController(
      @Autowired private val userService: UserService
  ) {
  
      @PostMapping(&quot;register&quot;)
      fun registerUser(@RequestBody user: User) {
          userService.registerUser(user)
      }
  
      @GetMapping(&quot;users&quot;)
      fun getUsers(): List&lt;User&gt; {
          return userService.getUsers()
      }
  
      @GetMapping(&quot;user/{id}&quot;)
      fun getUsers(@PathVariable(&quot;id&quot;) id: Long): User {
          return userService.getUserInfo(id)
      }
  }
  </code></pre>
  <p>My Request Payload is</p>
  <pre><code>POST http://localhost:8080/api/v1/register
  Content-Type: application/json
  
  {
      &quot;first_name&quot; : &quot;Abid&quot;,
      &quot;last_name&quot; : &quot;Affan&quot;,
      &quot;email&quot; : &quot;aminul15-5281@diu.edu.bd&quot;,
      &quot;gender&quot; : &quot;M&quot;,
      &quot;date_of_birth&quot; : &quot;2019-05-03&quot;,
      &quot;country&quot; : &quot;Bangladesh&quot;
  }
  </code></pre>
  <p>and my response payload is</p>
  <pre><code>POST http://localhost:8080/api/v1/register
  
  HTTP/1.1 400 
  Content-Type: application/json
  Transfer-Encoding: chunked
  Date: Mon, 01 Mar 2021 05:52:03 GMT
  Connection: close
  
  {
    &quot;timestamp&quot;: &quot;2021-03-01T05:52:03.634+00:00&quot;,
    &quot;status&quot;: 400,
    &quot;error&quot;: &quot;Bad Request&quot;,
    &quot;message&quot;: &quot;&quot;JSON parse error: Instantiation of [simple type, class com.example.demo.user.User] value failed for JSON property firstName due to missing (therefore NULL) value for creator parameter firstName which is a non-nullable type; nested exception is com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class com.example.demo.user.User] value failed for JSON property firstName due to missing (therefore NULL) value for creator parameter firstName which is a non-nullable type\n at [Source: (PushbackInputStream); line: 8, column: 1] (through reference chain: com.example.demo.user.User[\&quot;firstName\&quot;])&quot;,
    &quot;path&quot;: &quot;/api/v1/register&quot;
  }
  
  Response code: 400; Time: 214ms; Content length: 119 bytes
  </code></pre>