Hector
Hector

Reputation: 1220

Specifying to ServiceStack to send a parameter as a query parameter

I'm using the JsonHttpClient to communicate to an existing REST server. Is there any way to specify to send certain parameters as Query / form parameters?

Upvotes: 1

Views: 872

Answers (1)

mythz
mythz

Reputation: 143389

We don't recommend using ServiceStack's Service Clients for 3rd Party APIs, instead you can use HTTP Utils which are more flexible and will let you send queryString with:

var url = baseUrl
    .AddQueryParam("foo", 1)
    .AddQueryParam("bar", 2);

As well as a number of different APIs to send HTTP FormData, e.g:

var response = url
    .PostToUrl("Username=mythz&Password=password");

var response = url
    .PostToUrl(new Login { Username="mythz", Password="password" });

Upvotes: 3

Related Questions