Hi all,
I have a requirement where I need page.model.json when someone clicks on the activate page button. I am able to see the model.json by directly accessing using chrome but not able to do so in JAVA code.
Thanks,
@ashokkumarmarni
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
As suggested by Arpit, You can get JSON response in Java code, please check the reference code which I created in the past.
AEM - Get JSON response of an AEM Page
Views
Replies
Total Likes
Views
Replies
Total Likes
Could you please bit more clear like what you are trying to achieve here-
1. Are you trying to replicate the page through java code?
2. If yes then you can access the page.mode.json and replicate the page through java
Replicator replicator = ServiceUtil.getService(Replicator.class);
replicator.replicate(session,
ReplicationActionType.ACTIVATE, path);
Views
Replies
Total Likes
Thanks for the reply.
Our requirement is to push ".model.json" code of a page on activation to Couchbase DB.
For that, we are using custom transport handler, In "doActivate" method of Custom Transport Handler, we are calling following code to get json of mypage:
HttpServletRequest req = requestResponseFactory.createRequest("GET", "/content/website/mypage.model.json");
ByteArrayOutputStream out = new ByteArrayOutputStream();
HttpServletResponse resp = requestResponseFactory.createResponse(out);
We are getting empty response. If i call the same url in browser then i am getting expected json response
Views
Replies
Total Likes
Just tried through postman, it is similar trying from code-
Few things to note it requires authentication
1. When you access mode.json what error are you getting ,is it unauthorized?, one more thing to add try absolute url like http://localhost:4502/contentpath
2. When i tried from postman with username and password as admin i am getting proper response as below for we retail page-
Views
Replies
Total Likes
Have you got a chance to look into thise thread Is this possible to get .model.json from content path in Java class instead of hitting absolute url ...
It might help you.
Regards,
Arpit
Views
Replies
Total Likes
Hi,
As suggested by Arpit, You can get JSON response in Java code, please check the reference code which I created in the past.
AEM - Get JSON response of an AEM Page
Views
Replies
Total Likes
Request from postman or request from browser url are same, that is why it's working for you & us both.
But whenever we request it in java code through request - response way, we are getting empty response.
Out of box pages of we.retail & geometrix are giving proper json response either way.
Views
Replies
Total Likes
Thanks Arun, we have checked your code and it is working fine as it is a custom servlet and you are reading/iterating the node through code.
We are trying to get ".model.json" working as it is Out of Box and it works for we.retail & geometrix site.
Any help is appreciated. Thanks
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies