11

When I try to add RestSharp to a portable class library project using nuget, I get the following:

Could not install package 'RestSharp 104.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.0,Profile=Profile104', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I assume then it is not supported? If that be the case anyone have any suggestions on how to get this to work?

Daniel Plaisted
  • 16,674
  • 4
  • 44
  • 56
Eric
  • 3,632
  • 2
  • 33
  • 28
  • See http://stackoverflow.com/questions/13547479/are-there-any-rest-libraries-out-there-that-work-with-portable-class-libraries – Eric Dec 04 '12 at 13:27

4 Answers4

5

Another interesting option is Flurl

Flurl is a modern, fluent, asynchronous, testable, portable, buzzword-laden URL builder and HTTP client library.

Code snippet:

var result = await "https://api.mysite.com"
    .AppendPathSegment("person")
    .SetQueryParams(new { a = 1, b = 2 })
    .WithOAuthBearerToken("my_oauth_token")
    .PostJsonAsync(new { first_name = "Frank", last_name = "Underwood" })
    .ReceiveJson<T>();
Todd Menier
  • 37,557
  • 17
  • 150
  • 173
Nicola Iarocci
  • 6,606
  • 1
  • 20
  • 33
4

You have a portable RestSharp working at:

https://github.com/Geodan/geoserver-csharp/tree/master/RestSharp

It seems it's working well... It uses Json.net portable version too

Rui Marinho
  • 1,692
  • 12
  • 20
  • I'm unsure how to import this into Xamarin Studio. I have downloaded the branch, and added it as a new project, but it is unable to build because it missing almost every reference: `Microsoft.Threading.Tasks`, `Microsoft.Threading.Tasks.Extension`, `System.IO`, etc. Any point in the right direction? – edthethird Jun 16 '14 at 17:13
  • @edthethird I added this to my PCL using the NuGet package. I did have to add Microsoft.Bcl.Build myself because adding the RestSharp.Portable package didn't manage to add the former (although it tried). Once I added the ...Bcl.Build package myself, I was able to add RestSharp.Portable. – bcr Oct 27 '14 at 04:51
2

You may try RestSharp.Portable. This is a library which offers an API very similar to RestSharp.

Mark
  • 450
  • 2
  • 10
0

You may also want to look at PortableRest. Again, provides similar capabilities (and adheres closely to the API style) to RestSharp for .NET 4.5, Silverlight 5, Windows Phone 8.x, and Windows 8.x, as well as iOS and Android through Xamarin.

WickedW
  • 2,331
  • 4
  • 24
  • 54