3

I want to execute this curl command from a java application. I know I can use the Process Builder, but I dont know how to correctly format the command.

curl -X POST -d '{"user":"hello","command":"activate"}' "http://<examplewebaddress>"

This is what I have tried:

ProcessBuilder testCurlCommand = new ProcessBuilder("curl", "-X", "POST", "-d", "user=hello", "-d", "command=activate", "http://exampleweaddress>"

I have also tried many different variations of that incorporating the curly brackets, but it doesn't like that. Everything else works but I am unsure of the formatting for the arguments

11
  • 1
    Maybe it is the correct format, maybe it isn't - try it! Commented May 31, 2016 at 21:02
  • So this i Java question or CURL syntax question? Is it question after all ?\ Commented May 31, 2016 at 21:05
  • Welcome to StackOverflow. Please have a look at some helpful tips on how to ask a good question - asking a good question improves your chances of getting an answer. But it is also equally important that you search first and do some research before posting your question. Also include what you have tried and indicate the problem(s) you are experiencing. Commented May 31, 2016 at 21:05
  • I want to run this command in a java application using the process builder which the syntax will look something like: ProcessBuilder testCurlCommand = new ProcessBuilder("curl", "-X", "POST", "-d","user=hello", "command=activate", "http://<examplewebaddress>" but this doesnt work, I dont know how to format it with the brackets and such. Commented May 31, 2016 at 21:12
  • To clarify your question use edit option. Commented May 31, 2016 at 21:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.