I think the problem might rely on the (un)marshaller not being present or maybe just that the call you are using to test doesn’t include the Content-Type header. I’ve tested it with the following snippet and it works:
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.server.{ HttpApp, Route }
import spray.json.DefaultJsonProtocol
case class Person(name: String, favoriteNumber: Int)
object PersonJsonSupport extends DefaultJsonProtocol with SprayJsonSupport {
implicit val PortofolioFormats = jsonFormat2(Person)
}
import PersonJsonSupport._
class Putt extends HttpApp {
override protected def routes: Route = put {
pathEndOrSingleSlash {
entity(as[Person]) { person =>
complete(s"-$person-")
}
}
}
}
object Putt extends App {
new Putt().startServer("localhost", 8888)
}