Search code examples
intersystems-cacheintersystems

What is the best practice to read full POST request body when using REST in Caché?


Having the following UrlMap:

<Routes>
   <Route Url="/SaveSomething" Method="POST" Call="Save"/>
</Routes>

What is the best (easiest?) way to read full request body, without string length limitations ($$$MaxStringLength) or anything that may cut off some data?

In my case the purpose of this is to place the contents into a global.


Solution

  • Something like that would work:

    // %request.Content is a %CSP.BinaryStream
    set ^global = ""
    while '%request.Content.AtEnd {
       set ^global = ^global _ %request.Content.Read($$$MaxStringLength)
    }
    

    About %request