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?
Asked
Active
Viewed 773 times
1 Answers
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" });
-
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