Scalatra params not working on HTTP POST request

93 Views Asked by At

im getting "" for username and country_code with the correct request body but params are working fine in GET request so whats the problem here?

  post("/api/clients") {
    try {
      val username = params.getOrElse("username", "")
      val country_code = params.getOrElse("country_code", "")
      val client = new Client(username, country_code)
      if (client.getId == 0) {
        db.save(client)
        Ok(client.getId)
      } else {
        BadRequest("Bad Request")
      }
    } catch {
      case e: Exception => BadRequest("Bad Request")
    }
  }
0

There are 0 best solutions below