How do I call REST services from the Portable Class Library?


My target projects are Windows 8, WinRT and Windows Phone 8. I am using Portable Class Libraries for the solution in order to share the sources. I need to call some REST services created in another MVC Web Api project but HttpClient class is not available in the PCL. Which would be a good approach to solve it? I was thinking in a service interface and then to create a project for each platform, using HttpClient, WebClient or the appropriate class in each case. This approach could work but I was wondering if there are other ways.

HttpClient is not necessarily portable from Microsoft's view. The only other way is to create separate libraries that each project will implement, and do as you have described. This way, you can achieve commonality across all the platforms you desire to target.

I thought there was some level of equivalency when it came to the platforms you are targeting... If you have to have separate projects, you could link your code files to the other project so you don't have to maintain multiple projects, or even use Project Linker (though I don't know if a 2012 version exists).