I am trying to run the following curl command through java.This runs properly from the command line, but throws error when i run it using java
curl -XPOST -H'Content-type: application/json' "http://localhost:8084/druid/v2/?pretty" -d'{"queryType":"timeBoundary","dataSource":"wikipedia"}'
This is the java code using processbuilder:
ProcessBuilder pb1 = new ProcessBuilder(
"-XPOST",
"-H", "Content-Type:application/json",
"http://localhost:8084/druid/v2/?pretty",
"-d", "{\"queryType\":\"timeBoundary\",\"dataSource\":\"wikipedia\"}"
);
Process shell = pb1.start();
This is the error i am getting.
Exception in thread "main" java.io.IOException: Cannot run program "-XPOST": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at com.druid.DruidConnection.main(DruidConnection.java:69)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:187)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 1 more
XandPOST. The same applies to other options as well"-X POST"and"X","POST". I have tried. both throws error.