mercredi 26 août 2015

Using fiddler to test my WEB Api . Which content type to select and the input parameter is always null

I created a Web API which accepts Json string and returns an XML. I am trying to test my web API using fiddler and unable to test it.

My get method in code:

[HttpGet]        
        public XmlDocument GetXML([FromBody]string JsonString)
        { 
            System.Xml.XmlDocument xmlDocument = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(JsonString);

In fiddler :When I provide the content type as application json(below is screen shot). It throws a HTTP 500 error. "An error has occurred.No MediaTypeFormatter is available to read an object of type 'String' from content with media type 'application/json'."

But when I provide the content-Type :application/xml. It successfully makes a connection to the web api but the Input parameter "JsonString" is null. enter image description here




Aucun commentaire:

Enregistrer un commentaire