DeliveryApi: Simple code to return publishContent as Delivery Api Content JSON format
Hi,
I wish to write a simple code that I searched and tested to return the JSON like Delivery API and not overloaded like to return direct Content Type.
Do you have some suggestions?
How to query the data with DeliveryApi SDK?
using Umbraco.Cms.Core.DeliveryApi;
.... inject interface:
private readonly IApiContentQueryService _apiContentQueryService;
private readonly IApiContentRouteBuilder _apiContentRouteBuilder;
private readonly IApiContentBuilder _apiContentBuilder;
public DemoController(
.... IApiContentRouteBuilder apiContentRouteBuilder,
IApiContentBuilder apiContentBuilder
)
{
....
_apiContentQueryService = apiContentQueryService;
_apiContentRouteBuilder = apiContentRouteBuilder;
_apiContentBuilder = apiContentBuilder;
}
public async Task<IActionResult> Content(int id)
{
var content = _contentService.GetById(id);
if (content == null)
return NotFound();
var flag = await IsAuthorizedToSeeData(id, email);
if (flag)
{
var iii = _apiContentRouteBuilder.Build(_publishedContentQuery.Content(id));
var cc = _apiContentBuilder.Build(_publishedContentQuery.Content(id));
return Ok(cc);
}
else
return Unauthorized();
}
DeliveryApi: Simple code to return publishContent as Delivery Api Content JSON format
Hi,
I wish to write a simple code that I searched and tested to return the JSON like Delivery API and not overloaded like to return direct Content Type. Do you have some suggestions? How to query the data with DeliveryApi SDK?
is working on a reply...