Expand my Community achievements bar.

SOLVED

Can we publish page using groovy script?

Avatar

Level 2

Hi , i have a use case to get the page from my node path and publish it using groovy script. Can we achieve this using groovy and if so could someone help me with a pseudo code . Thanks

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
4 Replies

Avatar

Level 7

Hi @Zendark 

Using JS I believe you can do something like:

const bodyParts = new URLSearchParams();
bodyParts.append(':operation', 'activate');
bodyParts.append(':path', '/content/my/page');

fetch('http://localhost:4592/bin/replicate', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'Authorization': 'Basic YWRtaW46YWRtaW4='
    },
    body: bodyParts
})
 

 

I used something like this i a previous post, but for a different use case: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/suggestions-to-extract-con...

I have not tried that js for replication, maybe it has some bugs, but at least might give you a glimpse into what api your groovy script needs to call.

Avatar

Correct answer by
Community Advisor

Hi, 

Please check this; https://stackoverflow.com/questions/32958010/adobe-cq-aem-groovy-to-activate-a-page

 

Hope this helps



Esteban Bustamante

Avatar

Level 7

@EstebanBustamanteI also was not aware about this. Thank you for sharing. I learned smth new today.

Avatar

Level 5

Yes, you can use the method activate(String path) to activate the passing the path ex: activate("/content/page").