1

I run a local ServiceStack service by using the template from the docs.

I'd like to be able to POST information. Get works fine, but I need it to be able to POST data including a body. I test this using postman, which works fine as well. The data contained in the body consists of two key-value pairs (string).

This question describes the problem I have, but with HTTPClient instead of ServiceStack. The following snippet shows the method I use for my GET request.

var client = new JsonServiceClient("http://192.168.0.5:12345/hello");
try
{
    HelloResponse response = await client.GetAsync(new Hello{ Name = Username ?? "" });
}
Marcel
  • 917
  • 3
  • 19
  • 48

1 Answers1

1

If you want to send a HTTP POST request instead of a GET Request, you'd just use the Post API, e.g:

await client.PostAsync(requestDto)

If you want to send a raw POST body in addition to Request DTO properties your Request DTO needs to implement IRequiresRequestStream then you can use the PostBody API, see the ServiceStack docs for details.

mythz
  • 141,670
  • 29
  • 246
  • 390