Just as an exercise I'd like to create an ASP.Net web API which converts between XML and JSON.
this is what I have so far:
I think the content type checking is right, but I can't test as I am getting "Method not Allowed" when I try and post, is it possible to have routing/binding to achieve my goal?
I am trying to test this with Fiddler:
my routes look like this:
my webapi routes look like this:
but I still get Method Not Allowed :=/
jsonOrXml
in your Post action. You will have to read it from the request body. It won't come as parameter. Or if you want it to you will have to write a custom model binder or formatter. – Darin Dimitrov Oct 16 '13 at 14:35~/App_Start/WebApiConfig.cs
. Also from your Fiddler screenshot I can see that you have provided invalid JSON payload:{sample:"true"}
. A valid JSON should look like this:{"sample":"true"}
. – Darin Dimitrov Oct 16 '13 at 14:58