Using the rest 4 template. I have a POST method defined, with an object as a parameter. REST 4 does a great job of automatically mapping both xml and json posts to the method. I tested this using an HttpClient test application to build and post xml content and then json content.
I want to also support a standard form post to the method but am having problems!
I'd like the same method already accepting and converting both xml and json to also work correctly for a form post. I am testing this by creating an HttpUrlEncoded form in the test client, adding form name/value pairs that match what the method is expecting, and trying to post it.
However I get a 400 Bad Request. Here's some example code that is returning a 400 bad request:
var client = new HttpClient();
HttpUrlEncodedForm form = new HttpUrlEncodedForm();
form.Add("Message", "Message test with 'special' chars #!#");
var response = client.Post("<valid-uri-here>", form.CreateHttpContent());
View Complete Post