Problem Using AEM code to run the Curl command by accessing DAM assets | Community
Skip to main content
Umamaheswari_Yakkala
Community Advisor
Community Advisor
March 17, 2023

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

  • March 17, 2023
  • 1 reply
  • 1192 views

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
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Magicr
Level 6
March 17, 2023

And which problems do you have exactly?

Umamaheswari_Yakkala
Community Advisor
Community Advisor
March 17, 2023

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();
Magicr
Level 6
March 17, 2023

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"