Expand my Community achievements bar.

SOLVED

How to make infinity.json or model.tidy.json work in publish instance?

Avatar

Level 4

I want to get the content of a page as json and I want to consume that from an external application. When I tried in author, it works. But it doesn't work in publish instance. Please help on how to make it work on publish instance.

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

This should be avoided on publish, because it exposes all JCR properties (including cq:lastModifiedBy properties, which can contain usernames/email addresses). Instead you should define Sling Models and use the Sling Model Exporter to make it available as JSON.

View solution in original post

6 Replies

Avatar

Community Advisor

hi @rakesh_h2 ,

Please check in dispatcher filters if model.json is allowed. For eg like below

 

# Allow components JSON model
/0101 { /type "allow" /extension "json" /selectors "model" /path "/content/*" }

Avatar

Correct answer by
Employee Advisor

This should be avoided on publish, because it exposes all JCR properties (including cq:lastModifiedBy properties, which can contain usernames/email addresses). Instead you should define Sling Models and use the Sling Model Exporter to make it available as JSON.

Avatar

Community Advisor

Hello @rakesh_h2 

 

Can you share the publisher logs to understand what happens when you are trying to access the content of a page as json in publisher?

Avatar

Community Advisor

Hi @rakesh_h2 
To expose the pages content as json, use sling model exporters which implements component exporter to expose data as json and allow them in the dispatcher rules.
To expose specific page content as json write a servlet as provided in the link (http://www.nateyolles.com/blog/2015/12/converting-aem-sling-resources-to-json) by excluding OOTB JCR properties and allow the servlet path in dispatcher.

Avatar

Community Advisor

Hi @rakesh_h2 ,

For publisher model.json is restricted to access from dispatcher end. If you want to access the json then add Sling Model Exporter in your model class for the component whichever you are using in your page, also for accessing the page properties data you can add the exporter in your page model class.