How can I retrieve the HTTP POST
request body when implementing NanoHTTPDs serve
method?
I\'ve tried to use the getInputStream()
m
On a IHTTPSession
instance you can call the .parseBody(Map
method which will then fill the map you provided with some values.
Afterwards your map may contain a value under the key postBody
.
final HashMap map = new HashMap();
session.parseBody(map);
final String json = map.get("postData");
This value will then hold your posts body.
Code that does this, can be found here.