Accessing Response Content in %CSP.REST Before Writing to Output Buffer
Hello Community,
When handling a %CSP.REST API response for a custom endpoint, how can I capture or access the response content before it is written to the output buffer and sent through the Web Gateway to the UI?
In manually created REST services (for example, with a route like:<Route Url="/test" Method="POST" Call="User.Sample:Test" Cors="true"/> ),
the response is typically written from within any class method in the execution flow.
Is there a way to intercept or log the response content before it is sent to the client?
Thanks!
Comments
It's not possible, the response is "sent to the browser" (via Web Gateway....) immediately, there is no buffer or anything.
If you want to capture YOUR response, put it in a buffer and when you are done, send it from your buffer "to the browser"
That's my understanding as well. So, Once the response is written and sent, it cannot be tracked afterward—except through the Web Gateway HTTP trace.
There was something similar: Event onPostDispatch %CSP.Rest or similar
Hello @Vitaliy Serdtsev
Thank you for pointing the %CSP.SessionEventsclass to capture the end of request. However, my requirement is to intercept the written API response by class method before it's sent to UI.