I'm trying to make an api that returns a list ( json ) of the result of an examine search. This doesn't work. It says it can't serialize PublishedSearchResult.
Any ideas - or maybe a different and better way to approach it?
public class SearchController : UmbracoApiController
{
[HttpGet]
public IEnumerable<PublishedSearchResult> GetResults(string term)
{
var result = Umbraco.ContentQuery.Search(term);
return result;
}
}
[HttpGet]
public JsonResult<List<Node>> GetResults(string term)
{
var result = Umbraco.ContentQuery.Search(term);
List<Node> nodes = new List<Node>();
foreach(var item in result)
{
nodes.Add(new Node
{
Name = item.Content.Name
});
}
return Json( nodes);
}
}
public class Node
{
public string Name { get; set; }
}
Api - Examine results
Hi
I'm trying to make an api that returns a list ( json ) of the result of an examine search. This doesn't work. It says it can't serialize PublishedSearchResult.
Any ideas - or maybe a different and better way to approach it?
Ulrik,
That wont work, you need to maybe create your own pocos and transform your results to list of those pocos and return those.
Regards
Ismail
Thanks Ismail
That works :)
is working on a reply...