Expand my Community achievements bar.

SOLVED

Aem 6.5 - Customized ModelExporter

Avatar

Level 4

HI,

 

in Adobe Aem 6.5 cloud version I would like to create a customized ModelExporter to export some page contents to json.

 

I would like my ModelExporter to respond to the following url: http://localhost:4502/content/my-page.my-seolector.my-extension where my-seolector sees to be different from "model" and my-extension different from "json ".

 

I tried to make a mapping of the following type but it doesn't work:

 

@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL, resourceType = "xxx/components/structure/page")
@exporter(name = "jackson", selector = "my-seolector", extensions = "my-extension", options = { @ExporterOption(name = "SerializationFeature.WRAP_ROOT_VALUE", value = "true")})

 

Could you tell me how to do it?

 

Thank you

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

It seems you need to configure custom mime type in Apache Sling MIME Type Service as explained on

https://taradevko.com/aem/sling-model-exporter-now-really-custom/

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

It seems you need to configure custom mime type in Apache Sling MIME Type Service as explained on

https://taradevko.com/aem/sling-model-exporter-now-really-custom/

Avatar

Community Advisor

Hi @robertol6836527 
You sling model exporter declaration is fine, can you post what exact error are you getting.
Also can you try with url http://localhost:4502/content/my-page/jcr:content.my-seolector.my-extension as the resource type for page is actually at the page content node.
So maybe sling model exporter is not getting triggered.
If none of this works , check in error logs if anything is breaking or any exception is there when you are hitting the sling model exporter url.