1

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?

Hector
  • 1,170
  • 2
  • 10
  • 27

1 Answers1

3

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" });
Community
  • 1
  • 1
mythz
  • 141,670
  • 29
  • 246
  • 390
  • Thanks. I'd been hoping to take advantage of the client API - but I guess what I need isn't currently supported. I take it you wouldn't consider implementing this via the Swagger attributes? The issue I have is the API expects a mixture of query parameters and body. – Hector Jan 10 '17 at 08:37
  • @user2036256 Not for the Service Clients which are optimized for consuming ServiceStack Services. – mythz Jan 10 '17 at 08:41