Search code examples
swiftserver-sidekitura

Post gives Request Body as nil in Kitura


I tried posting a request to my localhost with a json body from REST CLIENT & POSTMAN and also from terminal. But always the request.body is nil. Using package : .Package(url: "https://github.com/IBM-Swift/Kitura", majorVersion: 1, minor: 1).


Solution

  • Please make sure that you have added the BodyParser middleware to your routes. For example:

    let router = Router()
    
    router.all(middleware: BodyParser())
    

    Shmuel Kallner