I am using Spring with Java 11.
I have a test curl command that I can call successfully via java.
final String cmdGetDocId = "curl -X POST https://postman-echo.com/post --data foo1=bar1&foo2=bar2";
Process process = Runtime.getRuntime().exec(cmdGetDocId);
InputStream inputStream = process.getInputStream();
JSONObject json = convertToJSON(inputStream);
The returned JSON is as expected.
If I use a different curl and execute it on the command line, it returns some JSON successfully as expected.
curl --location --request GET 'http://xxx.xx.xx.xx:8080/document/details/' --header 'Authorization: Basic xxxxx'
However, if I try to call the curl from my Java application, it fails.
String cmdGetDocId = "curl --location --request GET 'http://xxx.xx.xx.xx:8080/document/details/' --header 'Authorization: Basic xxxxx'";
Process process = Runtime.getRuntime().exec(cmdGetDocId);
InputStream inputStream = process.getInputStream();
JSONObject json = convertToJSON(inputStream);
The returned inputStream is empty.
Do you know what I am doing wrong? Why can the java method call the test curl but not the other GET curl?