I am aware there exists questions answered on this but I wanted to ask as it is different from the rest.
I am trying to send a curl request using subprocess and cannot get a variable to funcion:
 config = json.loads(open('/etc/config.json').read())
    endpoint = config["end_point"]
    auth = config["auth_token"]
    config["widgets"]
    #Send using subprocess
    import subprocess
    subprocess.call([
    'curl',
    '-X',
    'POST',
    '-H',
    'Content-Type: application/json',
    '-d',
    '{ "auth_token": **'auth'**, "widget": "329bdbea887ad8e10e4e496f7a60f898", "title": "Something", "items":[{"label": "testR", "value": "$999.99"}, {"label": "testB", "value": "$9,001.00"}] }',
    **'endpoint'**
The config file contains the following:
{"end_point":"http://domain.com","auth_token":"e91a0ffe758c19=ed0","widgets":{"host_info":"fd8a63ads499289a312","memory_info":"0bc2c24ds28bc4c507ad","cpu_info":"5assd0dc41dbd73681"}}
Neither auth not endpointurl is not working.
Full code is:
import subprocess subprocess.call([ 'curl', '-X', 'POST', '-H', 'Content-Type: application/json', '-d', '{ "auth_token": "e91a0ffe758c194896eb4daed0", "widget": "329bdbea887ad8496f7a60f898", "title": "Something", "items":[{"label": "text2, "value": "$999.99"}, {"label": "text1", "value": "$9,001.00"}] }', 'http://domain.com' ])
I
Here I am trying to use auth variable instead of "e91a0ffe758c194896eb4daed0"