Receive string to endpoint without a DTO

I am integrating with a service that uses webhooks.

The service is a bit awkward because it send multiple different types of formats of webhooks but only allows receiving through a single endpoint.

With ServiceStack to define that endpoint I can do:

[Route("/webhook", "POST")]
public class WebHookRequest : IReturn<WebHookResponse>
{

}

and then

    public WebHookResponse Post(WebHookRequest request)
    {

    }

But I just want to receive the raw json string in the endpoint so I can save it to database as is as they have a tendency of changing the webhooks format.

In normal asp.net core I would set the method signature to an object then deal with it inside the method:

    public WebHookResponse Post(object request)
    {

    }

But in SS everything works from a DTO so how can I do this approach?

I found answer here: https://stackoverflow.com/questions/17514754/can-servicestack-runner-get-request-body

[Route("/webhook", "POST")]
public class WebHookRequest : IReturn<WebHookResponse>, IRequiresRequestStream
{
      public Stream RequestStream { get; set; }
}
1 Like