0

I am interested in getting the raw body of the HTTP POST request that comes to my endpoint when directly calling the URL where this endpoint lives (https://<my app name>.appspot.com/_ah/api/endpoints/v1/test) and supplying the body with it. Here is the method of the endpoint which successfully gets called:

 @ApiMethod(name = "test", path = "test", httpMethod = ApiMethod.HttpMethod.POST)
public WrappedBoolean test(final HttpServletRequest request, ServletContext servletContext) throws Exception {

    //???
    return new WrappedBoolean(true); 
}

Unfortunately, trying to retrieve the InputStream from the HttpServletRequest and then reading it, gives me a -1, meaning all the data has already been read. This makes sense, as the App Engine endpoints runtime has most likely already processed the request by now.

Anyone has a view on how to get a hold of the original POST request that was POSTed to this endpoint?

my chalupa
  • 137
  • 11

1 Answers1

0

Seems like there is no way to recover the original message easily. An additional manipulation would have to be done - something like placing a filter in front of the requrest, reading in the request, saving it in an attribute and grabbing that attribute during the endpoint call. All of this has to be done carefully, so as not to mess up the input stream for the SPI runtime (endpoints) to manage, otherwise, the endpoint wont be called. Anyhow, too big of a hassle. I abandoned doing something endpoints were really not meant for, and just directly employed a java Servlet.

my chalupa
  • 137
  • 11