Skip to content

Instantly share code, notes, and snippets.

@trnktms
Last active September 29, 2022 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trnktms/4c078509148c027e69c995a3744d8823 to your computer and use it in GitHub Desktop.
Save trnktms/4c078509148c027e69c995a3744d8823 to your computer and use it in GitHub Desktop.
using System.Net;
using System.Web.Mvc;
using Foundation.ContentsResolvers;
using Sitecore;
using Sitecore.LayoutService.Configuration;
namespace Feature.Controllers
{
public class CustomApiController : BaseApiController
{
public CustomApiController(
IDefaultRenderingContentsResolver defaultRenderingContentsResolver,
IConfiguration configuration)
: base(renderingConfigFactory, defaultRenderingContentsResolver, configuration)
{
}
[HttpGet]
public ActionResult Organizations()
{
var item = Context.Database.GetItem("/your/test/item/path");
var jsonResult = defaultRenderingContentsResolver.ProcessItem(i, renderingConfiguration)
return Content(jsonResult.ToString(), "application/json");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment