I need to export content fragments to target through custom workflow
I have a project where content fragments need to be automatically exported as JSON to a target location upon creation via a custom workflow. The JSON format should match what is generated when accessing the URL: http://localhost:4502/api/assets/contentfragment.model.json.
However, I am facing an issue where I can't replicate the exact JSON format needed for export. Despite my efforts with the code below, the resource resolver is unable to recognise the resource at api/assets.
Resource modelJsonResource = resolver.getResource("http://localhost:4502/api/assets/contentfragment.model.json");
if (modelJsonResource != null) {
InputStream jsonContent = modelJsonResource.adaptTo(InputStream.class);
if (jsonContent != null) {
sendToTarget(jsonContent);
}
}
Could someone help me achieve the expected JSON output?