I have successfully created a PHP REST API which resides on my server. I am now looking to create the client-side connection to this via my WPF C# application. I found this but my API requires the API key to be sent via a HTTP header, and I can't see you can do that in this. I also created a PHP REST client using CURL and it was very easy, and was hoping that there would be something built into C# to handle requests to REST services.
If someone could point me in the direction of a tutorial they have seen, or a library somewhere I would be grateful.
Thanks.
If your PHP REST API backend is documented with Swagger, e.g. using swagger-php, you can use swagger-codegen to generate the API clients in C#, Java, PHP, Ruby, Python and more using the Swagger spec that describes your PHP backend.
You might also want to check out Hammock.NET @ http://hammock.codeplex.com/ ; it is a joy to work with. You really don't need WCF in all likelyhood.
Also you can use HttpClient in .NET 4.5.
If you are usint .NET 4.0, the
HttpClient
API is available in Microsoft.Net.Http nuget.Take a look at RESTSharp. Very powerful, and easy to use.
Works on all platforms too: Web, Windows, WCF, Monotouch, Windows Phone
You can just use HttpWebRequest or WebClient to make web requests like you would have with CURL in your PHP client...
If you need to deal with JSON based responses, JSON.Net is a fantastic library.