Search code examples
nancy

Raw request Body Content


I'm developing Nancy web service that will collect data from clients which will send HTTP requests like this

POST /iclock/cdata?SN=3163602360001&table=OPERLOG&OpStamp=426433018 HTTP/1.1
Host: 218.108.223.49:9001
User-Agent: iClock Proxy/1.09
Connection: close
Content-Length: 4883
Accept: */*

OPLOG 0\tab 0\tab 2012-09-07 11:36:39\tab 0\tab 0\tab 0\tab 0
OPLOG 3\tab 0\tab 2012-09-07 11:36:42\tab 55\tab 0\tab 0\tab 0

Problem is, that I can't find a way to collect those data in Nancy module. Is there any way to get raw request body content inside Nancy module?


Solution

  • You can use .AsString() on the body tag to return the payload stream as the raw text passed from the client.

    e.g

    var body = Request.Body.AsString();