Is it possible to create a workflow that gets executed when a page gets published/unpublished to run a curl command like: curl <published_page_url>
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
yes, it is possible,
you can write a service or you can include steps as follow
yes, it is possible,
you can write a service or you can include steps as follow
Sharing a blog with code snippets to execute Curl commands via Java program
https://techrevel.blog/2018/01/19/curl-execution-from-java-program/
//Equivalent command conversion for Java execution
String[] command = { "curl", "-u", username + ":" + password, "-X", "POST", "-F", "cmd=unlockPage", "-F",
"path=" + path, "-F", "_charset_=utf-8", url };
ProcessBuilder process = new ProcessBuilder(command);
Process p;
try {
p = process.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder builder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
builder.append(line);
builder.append(System.getProperty("line.separator"));
}
String result = builder.toString();
System.out.print(result);
} catch (IOException e) {
System.out.print("error");
e.printStackTrace();
}
This will also hold good, when executed at end of workflow.
Other alternative to Curl is HTTP requests. All AEM curl commands can be converted into HTTP GET and POST .