Sunday 15 May 2011

servicestack - Sending a GET request to the path given in the route -


I am trying to call a RES service with a URL like this:

  example   

I have defined the request and response DTO. [Route ("/ account / {username}", "received")] Public class AccountRequest: Irene

Service calling:

  JsonServiceClient client = new JsonServiceClient ("http://example.org"); AccountRequest Request = New AccountRequest {UserName = "me"}; AccountResponse response = client.Get (request);   

However, when I call on the client, it does not respect the route. When I check in the cloud example debugger, AsyncOneWayBaseUri value is example.org/json/ asynconeway / . This part is irrelevant because it does not mean that the request has been sent to this URL. I do not really know where to send this request. I have not received any error and all my items are zero in the response object.

What am I missing here?

To call third party REST / HTTP Apis, you can use that service to Stack.Text, which can be accessed by normal data access To provide a brief, readable, pleasant API for NET Patterns around HttpWebRequest , such as:

  list & gt; GithubRepo & gt; Repos = "https://api.github.com/users/{0} /repos".fmt(user) .GetJsonFromUrl () .FromJson & lt; list & gt; GithubRepo & gt; & gt; ();   

Service # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # P #
  account request request = new account request {}  extension method (that service customer USS) directly (like without service call)  TRequest.ToUrl (method) Username = "me"}; Request.ToUrl ("GET") print (). //   

The same auto-generated route was used when I tried to call it through the JsonServiceClient , e.g.

  var clients = new JsonServiceClient ("http://example.org"); Var response = client.Get (request); // Call http://example.org/account/me   

Route URL to be used in service stack service customers

Service stacks are the most suitable route Trying to use the match DTO and HTP method with the value of the people you are calling with, if no mail is found, then it will fallback.

By default, the default predefined routes will be used:

 / api / [xml | Json | Html | Jsv Csv] / [syncreply | Asynconeway] / [servicename]   

But the service stack still supports / Reply and / oneway For example:

  / api / [xml | Json | Html | Jsv Csv] / [Answer | Care] / [Servicename]   

By setting the flag you can opt-in to use in customers:

  client.UseNewPredefinedRoutes = true;    

No comments:

Post a Comment