Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

How to accept JSON and XML both in Web API post method

$
0
0

Hi All,

I have written Web API code and my web service is able to accept JSON data sent from Advanced REST Client (Chrome app)

But unfortunately I am unable to get XML data on my web service POST method. Below is the code snippet.

        [HttpPost]
        public string Post([FromBody]object value)
        {
            try
            {
                MyClass obj = new MyClass();
                return obj.ProcessRequest(value.ToString());
            }
            catch (Exception Ex)
            {
                return Ex.Message;
            }
        }

I also tried string instead of object but no help.

Please advice.
   


Viewing all articles
Browse latest Browse all 4850


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>