get model.json while replicating page

ashish_mishra1

11-10-2019

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

Accepted Solutions (1)

Accepted Solutions (1)

Answers (7)

Answers (7)

ashish_mishra1

16-10-2019

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

ashish_mishra1

16-10-2019

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.

Ankur_Khare

MVP

11-10-2019

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-

1843646_pastedImage_1.png

1843549_pastedImage_0.png

ashish_mishra1

11-10-2019

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

Ankur_Khare

MVP

11-10-2019

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);