What REST client are you using?


I'm currently using RESTSharp.Portable to access REST services. I'm using this as I'm familiar with RESTSharp. What are you all using?



  • tkowalczyktkowalczyk PLMember, University ✭✭

    I am also using RestSharp but it is slow so I think to move to this https://github.com/paulcbetts/ModernHttpClient do you have any experience with ModernHttpClient and calling some REST API by this project?


  • MarkMadlangbayanMarkMadlangbayan USUniversity ✭✭

    I'm actually switching to ModernHttpClient as I'm having issues with RESTSharp.Portable with iOS. It seems that it won't support it.

  • IanVinkIanVink CAInsider, University ✭✭✭

    Rest sharp Plc version has worked well for me

  • AndyHopperAndyHopper USMember ✭✭

    We're using Flurl and are pretty happy with its fluent API.

  • SKallSKall USMember ✭✭✭✭

    HttpClient works well for me.

  • OtaMaresOtaMares DEMember ✭✭
    edited January 2015

    We are currently evaluating refit which i actually would love to use but given the fact that its missing a few features we need, like generic error handling or list parameters we might change to another library. In general the extensibility is very limited. Maybe that will come in a future time.

    @AndyHopper‌ Does Flurl support json.net?

  • AndyHopperAndyHopper USMember ✭✭

    @OtaMares‌ Yep! Furl.Http has it as a dependency.

  • seansparkmanseansparkman USInsider, University, Developer Group Leader mod

    Json.NET and plain ole HttpClient

  • IanVinkIanVink CAInsider, University ✭✭✭

    I just had a look at http://tmenier.github.io/Flurl/ , it looks very interesting....

  • OtaMaresOtaMares DEMember ✭✭

    Yeah, based on the documentation we decided to give Flurl a spin in favor of refit. I'll come back when our decision is through :)

  • MartinRothschinkMartinRothschink DEMember ✭✭

    JSON.Net and HttpClient

  • ianmercerianmercer USMember ✭✭

    HttpClient with an awaitable SemaphoreSlim around any request methods to limit simultaneous requests (too many seems to cause _wapi_connect: error looking up socket handle errors on Android).

    Json.net for serialization and deserialization.

    Also, using only the methods on HttpClient that accept a CancellationToken and a timeout.

    With the semaphore and the cancellation token the UI can fire off multiple requests as you page through data but can also easily cancel them if they are no longer needed. Requests above, say, 2 simultaneous requests get queued up on the SemaphoreSlim. When they acquire the semaphore they immediately check the cancellation token and if its set they abandon before making a request. If each cell in a grid has its own CancellationTokenSource you can queue up a request as each cell is requested but can cancel it each time a cell is reused (which may happen before the request is actually made). This way you can create a responsive, fast-scrolling grid even when each cell is being fetched from a remote source.

  • GeoffArmstrongGeoffArmstrong CAMember ✭✭

    Pretty plain Json.NET and ModernHttpClient.

  • TektonTekton USMember ✭✭✭

    @Ota Any updates? :smile:

  • OtaMaresOtaMares DEMember ✭✭

    @Tekton Yep! We decided to go with flur as it offers everything we need: easy rest consumption, no limitations regarding the feature scope, configurable error handling, active maintenance and good performance combined with ModernHttpClient.

    Besides all that its easy to learn and has a good documentation. We are super happy with it and i can only recommend it.

    Feel free to ask further details. :)

  • NMackayNMackay GBInsider, University mod

    We used ModernHttpClient but had to drop it as you need the pro version to handle untrusted certificates which was $400, HTTPS caused issues for us (and other people) when using emulators (Genymotion and iOS simulators), DNS issues which required using IP addresses for simulators and the ServerCertificateValidationCallback workaround.

    ModernHttpClient is noticeably quicker though and extremely easy to drop into your project if you've been using HttpClient (as we are at the moment). It's well worth a look.

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @MarkAM and all other reader of this thread:

    A wile ago, I have posted a thread especially to modernhttp-client, which also can be interesting for you.


  • xinmengxinmeng GBMember ✭✭

    @IanVink said:
    Rest sharp Plc version has worked well for me

    Are you sure the Restsharp support PCL? I cannot install in in PCL through Nuget


  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    As @AdamP just recommended refit to me, perhaps he can add his view on the different REST components

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    My opinion doesn't really move from the consensus here.

    Refit is good, Flurl looks good but haven't used it.

    I always use ModernHttpClient where possible on top of the Microsoft.Net.Http client. And I haven't used RestSharp since my WPF days and wow just checked, it still looks like it doesn't have PCL support.

  • ChaseFlorellChaseFlorell CAInsider, University mod

    +1 for good ol' HttpClient mixed with ModernHttpClient. One difference for me is that I've got a RestService wrapper around it for basic GET/PUT/POST/DELETE.

  • JulienRosenJulienRosen CAMember ✭✭✭✭
    edited April 2016

    Here is some code using RestSharp hitting a Rest API from a PCL

    var client = new RestClient(ApiUrl);
    request = new RestRequest(url, Method.GET);
    response = await client.Execute<TReturnType>(request);

    Edit: looks like I am using this

  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    @AdamP Is refit based on HttpClient too? Can it use ModernHttpClient?

  • AdamBennett.7253AdamBennett.7253 USMember ✭✭

    JSON.Net and HttpClient here as well

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @ThomasBurkhart - yes you can use ModernHttpClient with Refit

    var client = new HttpClient(new NativeMessageHandler()) { 
       BaseAddress = "http://foo.com"
    var service = RestService.For<IFooApi>(client);

    From https://github.com/paulcbetts/refit/issues/42

  • MichaelDimoudisMichaelDimoudis AUUniversity ✭✭

    I just released an app internally (not app store yet), but Refit with ModernHttpClient has been working really great, using Polly and have even thrown in Fusillade too.

    @OtaMares How do you mean Refit doesn't support generic error handling? You can do that like this:
    [Get("/api/getstuff")] [Headers("Authorization: Bearer")] IObservable<HttpResponseMessage> GetStuff();

    And then use Polly (you actually don't have to) to see if the connection succeeded, if not you can get the error message out.

    var response = await Policy.Handle().WaitAndRetryAsync(RETRYLOGICHERE)
    .ExecuteAndCaptureAsync(async () => await YOURAPICALLHERE);

    if (response.Outcome == OutcomeType.Successful && response.Result.IsSuccessStatusCode){
    Thing here is you'll have to deserialize the object yourself.
    var content = JsonConvert.DeserializeObject(await response.Result.Content.ReadAsStringAsync())
    } else {

  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    @MichaelDimoudis If I have to deserialize the Object ton my own, what sense makes it to use refit then, just to make the requests easier?

  • MichaelDimoudisMichaelDimoudis AUUniversity ✭✭

    @ThomasBurkhart Good point, I didn't start off like that, obviously I let Refit deserialize initially, but then changed for better error codes. However the main benefits Refit gives you are still there.

    Ie: just decorating the interface with the verbs you want, letting refit do the rest

    Ie: Auto injecting Auth header if you need auth for the API call
    [Headers("Authorization: Bearer")]

    Ie: Adding body object and getting Refit to deserialize it automatically
    IObservable Add([Body] AddModel addModel);

    Ie: Adding headers and attachments automatically
    Task UploadImage(string uniqueId, [Header("UniqueFileName")] string uniqueFileName, [Header("fileSize")] long fileSize, [AttachmentName("image.jpg")] Stream stream);

    Heaps of benefits :smile:

  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    @MichaelDimoudis Thanks a lot. I'm making my very first Steps with REST, so any this is really helpful to me.

  • NMackayNMackay GBInsider, University mod

    I've got by with HTTPClient and json.net so far. ModernHttpClient is very good but $400 just to handle certificate callbacks wasn't an option. HTTPClient is a bit quicker than when I 1st started in the Xamarin world too. I'm sure Microsoft will improve things.

  • MichaelDimoudisMichaelDimoudis AUUniversity ✭✭

    Why would anyone need the pro version of ModernHttpClient for? Just create a subdomain for your dev test API such as test-api-dev.mydomain.com and use the free letsencrypt.org service to get a free SSL certificate for your dev machine...

  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    Hi @MichaelDimoudis the tip with letsencrypt.org is awesome, As I will nee a certificate for my App and getting one free is just great.

  • I'm a bit confused about the need for ModernHttpClient's Pro version mentioned in this topic. Our QA environment uses self signed certs, and I have no problem hitting it using the code below. As far as REST clients, my experience with Refit has been good so far (but the API for my project is fairly simple).

    public sealed class HttpClientFactory
        : IFactory<HttpClient> // just an interface with the Create method
        private const string OurCert = "O=My Company Name";
        static HttpClientFactory()
          ServicePointManager.ServerCertificateValidationCallback +=
        public HttpClient Create()
          var handler = new NativeMessageHandler(true, true) {
            ClientCertificateOptions = ClientCertificateOption.Automatic
          return new HttpClient(handler);
        private static bool ValidateServerCertificate(object sender,
          X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
          if (errors == SslPolicyErrors.None)
            return true;
          return cert.Issuer.IndexOf(OurCert) >= 0;
  • tmeniertmenier USMember ✭✭
    edited August 2017

    I realize this is an older thread, but for anyone interested, Flurl plays very nicely with ModernHttpClient.

  • MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭

    As above, I realize this is an old thread but it's still relevant. There are a lot of Rest Clients around that are a lot better than RestSharp these days. My library is RestClient.Net. It was designed with Xamarin in mind from the ground up. There is a Xamarin.Forms sample contained in the repo if you clone it. Just open the RestClient.Net.Samples.sln solution.

    This folder is where the projects for each platform are located. It runs on Android, iOS, and UWP.

    Personally, I prefer RestClient.Net to Flurl, but I must say that after evaluating a lot of clients @tmenier has a point. If you're not going to use RestClient.Net Flurl is definitely a good option.

This discussion has been closed.