Feedback Request

UPDATE: The change described below has been committed to the GitHub repository.

While looking at the examples for a new .NET REST library that’s recently been released, one thing stuck out to me as a good idea to steal and implement in RestSharp. It has to do with what is returned from Execute methods.

Which do you prefer:

1. The Status Quo

RestClient client = new RestClient();
RestResponse response = client.Execute(request);
var statusCode = response.StatusCode;

Product product = client.Execute<Product>(request);
var name = product.Name;

2. Always return a RestResponse, sometimes with the entity

RestClient client = new RestClient();
RestResponse response = client.Execute(request);
var statusCode = response.StatusCode;

RestResponse<Product> responseWithData = client.Execute<Product>(request);
var code = responseWithData.StatusCode;
var name = responseWithData.Entity.Name;

I’m leaning towards #2 because it gives you access to the complete response details on every request.

Your thoughts?

Posted March 28th, 10:14 PM
Read more posts about Announcements.

View Comments
Link

  • Agree on the later being very usefull. Why not use Execute as a syntax for 1st style and ExecuteRequest(request) for the 2nd ?
  • I think this is an awesome idea.
blog comments powered by Disqus