'How can I pass args to a curl request executed via boost::process:child?
I'm able to execute a http POST request using curl via boost::process::child by passing the entire command line. However, I would like to pass the arguments via boost::process::args but I cannot get it work.
This works:
const std::string cmdDiscord = "curl -X POST https://discord.com:443/api/webhooks/1234567890 -H \"content-type: application/json\" -d \"{\"content\": \"test\"}\"";
boost::process::child c(cmdDiscord); // this works
boost::process::child c(boost::process::cmd = cmdDiscord); // strangely, this doesn't work
I want to use boost::process::args but this fails:
std::vector<std::string> argsDiscord {"-X POST",
"https://discord.com:443/api/webhooks/1234567890",
"-H \"content-type: application/json\"",
"-d \"{\"content\": \"test\"}\""};
boost::process::child c(boost::process::search_path("curl"), boost::process::args (argsDiscord));
The error is curl: (55) Failed sending HTTP POST request which is quite a vague error message. I couldn't find any examples calling curl. Does anyone have any suggestions on getting this to work?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
