Expand my Community achievements bar.

Problem Using AEM code to run the Curl command by accessing DAM assets

Avatar

Community Advisor

Hi Team,

 

    I am having trouble running this curl command using AEM code, and I need to read binary from DAM and send it to Curl. Any help would be greatly appreciated. 

or any other ideas how to achieve this.

String Path = "from Dam";
ProcessBuilder processBuilder = new ProcessBuilder(
"curl",
"-X",
"POST",
"--header",
"Authorization:Bearer xxxxx",
"--data-binary",
"@mar.txt",
"http://xxx.tt.omtrdc.net/m2/xxxx/v2/profile/batchUpdate"
);


Process process = processBuilder.start();

Thank You
Uma
4 Replies

Avatar

Community Advisor

The getting batch is empty when I use this method. I am not sure how can we pass this DAM file to Curl command. Any ideas

 

logger.debug("Inside updateProfiles");
String absolutePath = "http://localhost:4502/content/dam/batchuploadfiles/mar.txt";
ProcessBuilder processBuilder = new ProcessBuilder(
"curl",
"-X",
"POST",
"--header",
"Authorization:Bearer xxxxx",
"--data-binary",
"@mar.txt",
"http://xxxx.tt.omtrdc.net/m2/xxxx/v2/profile/batchUpdate"
);


Process process = processBuilder.start();

Avatar

Level 7

Have you tried your curl command in a console? If yes and it did work so I assume the path from you file is wrong. Usally "/content/dam/..." is the path for your asset. Any entries in error.log or any different logs? Properbly you have to add 

-F file=@"/content/dam/.../mar.text"

 

Avatar

Community Advisor

CUrl is working fine from the WSL terminal which is referring file from my drive location.

 

No other logs that I see.

 

I am requiring to do it from AEM .

 

Thank You,

Uma