ASP.NET MVC4 WebAPI and Posting XML data
I'm missing a trick with the new webapi - I'm trying to submit an xml string through a post request and not having much luck.

The front end is using jQuery like this:

        $(document = function () {
        $("#buttonTestAPI").click(function () {
            
            var d = " <customer><customer_id>1234</customer_id></customer>";
            $.ajax({
                type: 'POST',
                contentType: "text/xml",
                url: "@Url.Content("~/api/Customer/")",
                data: d,
                success: function (result) {
                    var str = result;
                    $("#output").html(str);
                }
            });
        });
    });

My controller is pretty simple at the moment - just the default for the post action - trying to return what was passed in:

        public string Post(string value)
        {
            return value;
        }

However, "value" is repeatedly null. The odd thing is, when I change my data in the jquery to be something like this:

    d = "<customer_id>1234</customer_id>";

Then I get "value" in my controller as 1234.

How can I get access to the more complex xml string in my controller?


ASP.NET MVC4 WebAPI and Posting XML data
===

I'm missing a trick with the new webapi - I'm trying to submit an xml string through a post request and not having much luck.

The front end is using jQuery like this:

        $(document = function () {
        $("#buttonTestAPI").click(function () {
            
            var d = " <customer><customer_id>1234</customer_id></customer>";
            $.ajax({
                type: 'POST',
                contentType: "text/xml",
                url: "@Url.Content("~/api/Customer/")",
                data: d,
                success: function (result) {
                    var str = result;
                    $("#output").html(str);
                }
            });
        });
    });

My controller is pretty simple at the moment - just the default for the post action - trying to return what was passed in:

        public string Post(string value)
        {
            return value;
        }

However, "value" is repeatedly null. The odd thing is, when I change my data in the jquery to be something like this:

    d = "<customer_id>1234</customer_id>";

Then I get "value" in my controller as 1234.

How can I get access to the more complex xml string in my controller?

