Reputation: 3826
An incoming request in my play application does not have the content-type headers attribute set. This makes accessing the body via
request.body.asText
problematic, as it seems the automatic parsing only provides the body via
request.body.asRaw
How can I handle the missing content-type attribute, to still be able to access the body (assuming it is parse able) via ".asText"
Upvotes: 1
Views: 367
Reputation: 11479
The tolerantText body parser will ignore the content type headers:
object MyController extends Controller {
def action = Action(parse.tolerantText) { req =>
val text = req.body
...
}
}
Upvotes: 4