14

I'm looking for the best .NET C# framework for building a REST Http client. My requirements are as follows:

  • Unit testable (mockable)
  • Supports multi-part form and file uploads

I have looked at Hammock, but it is lacking in documentation and seems to be troublesome when attempting to mock file uploads.

Any suggestions, please?

p.campbell
  • 91,713
  • 61
  • 243
  • 314
epoch
  • 1,307
  • 2
  • 15
  • 23
  • 1
    That Hammock link is dead BTW. I found the new [official Hammock page](https://github.com/danielcrenna/hammock) on Github but the author added a message on 2/19/2012 that he's not updating it anymore. There are some forks but none that are very active. – Brent Matzelle Mar 23 '12 at 15:44

6 Answers6

12

There is also RestSharp. I've inherited it on some projects and haven't fully explored it myself, so I'm afraid I cannot say if it meets your requirements.

The developer of RestSharp is active in the .Net community, so if the published documentation doesn't cover something I would say there is a good chance of getting some assistance.

Community
  • 1
  • 1
quentin-starin
  • 24,307
  • 6
  • 66
  • 84
  • I have looked at RestSharp. Does anybody know if there are any examples of mocking RestSharp clients? I see there are a few libraries that the author has put out (for services like Notifo) which have zero test coverage. – epoch Nov 01 '10 at 22:34
  • 1
    I'm the RestSharp dev. Our file uploads is not tested very well. We also don't do mocking very well, unless you want to build a custom IRestClient or IHttp implementation. If those are your two biggest concerns, I would go with Hammock. – John Sheehan Nov 01 '10 at 22:34
  • 4
    See my comment above. The Hammock author is no longer updating the project so RestSharp or Spring.Rest might be the better bet at this date and time. – Brent Matzelle Mar 23 '12 at 15:46
  • RestSharp -> ServiceStack recommendation (Jul '13 post comment, seems to remain valid as of Dec '18 based on other reading): https://stackoverflow.com/a/10118120/8352092 – dthal Dec 24 '18 at 19:57
4

You can also take a look to Spring.Rest client Framework : http://springframework.net/index.html#spring-rest-1.0.0-released

Cody Gray
  • 222,280
  • 47
  • 466
  • 543
bbaia
  • 1,173
  • 6
  • 8
3

Also take a look at the Microsoft.Http client in http://wcf.codeplex.com/ It will be included in future versions of the framework. It is relatively easy to unit test with.

Darrel Miller
  • 129,370
  • 30
  • 183
  • 235
  • +1 Now in ASP.NET MVC. See http://blogs.msdn.com/b/henrikn/archive/2012/02/16/httpclient-is-here.aspx for an example from a guy close to the dev of it – Ruben Bartelink Apr 16 '12 at 10:32
3

I have just submitted a patch for the aforementioned problem with mocking file uploads using Hammock and has been accepted into the trunk. See issue 13 for more details.

galpin
  • 56
  • 1
0

Microsoft HTTP Client Libraries is good option to consider.

Nuget URL - https://www.nuget.org/packages/Microsoft.Net.Http/

Srini
  • 588
  • 7
  • 22
0

Check the Flurl library https://flurl.dev/ Flurl is available on NuGet and is free for commercial use. It runs on a wide variety of platforms, including .NET Framework, .NET Core, Xamarin, and UWP.