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.
Aucun commentaire:
Enregistrer un commentaire