I am accessing the subprocess module to call a shell function. Part of the function call is a string:
data = '\'{"data": [{"content": "blabla"}]}\'' when passing the string, I get the following error:
from subprocess import check_output check_output(['curl', '-d', data, 'http://service.location.com'], shell=True) Error: raise CalledProcessError(retcode, cmd, output=output) ... returned non-zero exit status 2 I actually know the problem, it's that the string gets passed the way it looks to Python, escapes and all.
Using the console,
$ curl -d \'{"data": [{"content": "blabla"}]}\' http://service.location.com gives the same error, while
$ curl -d '{"data": [{"content": "blabla"}]}' http://service.location.com runs perfectly. Any ideas how to tell Python that it passes a string .. fully converted?
data = '{"data": [{"content": "blabla"}]}'instead ofdata = '\'{"data": [{"content": "blabla"}]}\''?