[System.Web.Http.HttpGet]
[System.Web.Http.Route("acDetails")]
[ResponseType(typeof(List<AutoCompleteCombine>))]
public IHttpActionResult acDetails(string Text)
{
var db = new ModelName();
var DetailsList = (IList)null;
try
{
var DetailsIListXX = (from a in db.Tablename
where a.ColumnName.StartsWith(Text)
select a.ColumnName).Distinct().ToList();
DetailsList = DetailsIListXX.Select(x => new { ColumnNameChange= x }).ToArray();
}
catch (Exception ex)
{
}
return Ok(DetailsList);
}
//properties
public class AutoCompleteCombine
{
public string ColumnNameChange { get; set; }
}
Above code works for 'application/json' and 'text/json' response types and gets error for application/xml and text/xml responses in swagger.
Exception Message:The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'
converting the response To List with AutoCompleteCombine class properties would fix the error i think.
Any suggestions to convert ilist to List in this object type case
Thanks