'HttpServletRequest unable to get body of request

I'm trying to create a little test servlet (Tomcat 10) to accept simple "POST" messages, however no matter what I've tried the servlet never seems to get the body (json).

I'm using Postman to send the messages (http).

I've tried getReader() and getInputStream() and both keep returning nothing. I've read that this can happen when the buffer has already been read, but I'm not reading it twice (not that I am aware of).

Here are some debug values:

getContentLength() => -1

getContentType() => application/json

getReader().ready() => false.

So, either no body was recieved or it was already read - but where? I've been using Postman for other API's without issue, so I don't believe I've done something wrong there, what else can I try within the servlet?

Does anyone have any suggestions of what I could try to get this working?

Update

Thank you @parsifal, I tested the servlet using PowerShell's Invoke-WebRequest and it worked perfectly, so I took another look at all my Postman settings, tested several things and then finally found my error. The Header parameter Content-Length wasn't selected - I had incorrectly assumed that it would be automatically sent, but it wasn't.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source