Install

Install-Package RestSharp

(or download)

Documentation

Get Started - All

Contributions welcome!

Discuss

RestSharp Google Group

Help and feature requests

Stay Updated

Follow @RestSharp

Subscribe to the RSS feed

Follow up to ‘Different Root on Error’ changes

In the process of implementing the changes described in this earlier post, I came upon what I think is a much more useful design that could be the start to more changes like this in the future. Instead of ErrorCondition and ErrorRootElement, which are too narrow to be useful outside of specific scenarios, I’ve changed it to work like the following instead:

var client = new RestClient(BaseUrl);
var request = new RestRequest("BadUrl");
request.RootElement = "Success";
request.OnBeforeDeserialization = resp =>
{
    if(resp.StatusCode == HttpStatusCode.BadRequest)
    {
        request.RootElement = "Error";
    }
};

var restResponse = client.Execute<RestResponse>(request);
// Write(restResponse.Message);

This gives you complete control to react to any response payload and adjust deserialization and other settings accordingly.

Release Update

While we’re here, an update on where things are at. The emergence of NuGet has pushed me to change my mind on releases and I’d like to get a 1.0 out. oAuth has been the big blocker here, but thanks to an idea from Daniel Crenna I think I’ve got a workable approach to get that in without having to try to shoehorn everything into an oAuthAuthenticator. That’s the last major hurdle to a first release. Once I’ve got the oAuthHelper implemented and a couple more issues from the issue tracker taken care of, there will be an official ‘RestSharp Release 1′.

If you have any feature requests or bugs, now is the time to get them in the system. If you’re not sure if it’s a bug or not, start with the Google Group.

Posted November 21st, 9:46 PM
Read more posts about Announcements.

No Comments Yet - Chime In
Link