I run a curl command on windows command line prompt. It produces a json
output. The command looks like this:
curl --data "action=details&user=user&project=project1&problemid=2021" https://website:9020/
I issue the same command in python as following:
import subprocess
output = subprocess.run(
[
"curl",
"--data",
"\"action=details&user=user&project=project1&problemid=2021\""
"https://website:9020/",
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True,
)
print(output.stdout.decode("utf-8"))
The output is the following:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 199 100 64 100 123 64 123 0:00:01 --:--:-- 0:00:01 1254
{"status":400,"message":"Action parameter is missing"}
But the command line produces a json output. Yet the same command issued through subprocess.run
produces this error. I also tried it with subprocess.Popen
and subprocess.check_output
. Same issue persists. What am I doing wrong here that is causing this error?