Error in getting margin with curl in Python

import requests

url = 'https://api.fyers.in/api/v2/span_margin'

headers = {

    'Authorization': client_token,

    'Content-Type': 'application/json'

}

data1 = {

    "data" : [

            {

            "symbol": "NSE:BANKNIFTY23O0443000CE",

            "qty": 15,

            "side": -1,

            "type": 2,

            "productType": "CNC",

            "limitPrice": 0.0,

            "stopLoss": 0.0

            }

            , {

            "symbol": "NSE:BANKNIFTY23O0443000PE",

            "qty": 15,

            "side": -1,

            "type": 2,

            "productType": "CNC",

            "limitPrice": 0.0,

            "stopLoss": 0.0

            }

            ]}

json_data = json.dumps(data1)

curl_command = [

    'curl',

    '--location',

    '--request',

    'POST',

    'https://api.fyers.in/api/v2/span_margin',

    '--header',

    'Authorization: xxx’,

    'header',

    'Content-Type: application/json',

    '--data-raw',

    json_data

]

try:

    output = subprocess.check_output(curl_command, stderr=subprocess.STDOUT)

    

    st.write(output.decode('utf-8'))  # Print the output as a string

except subprocess.CalledProcessError as e:

    print(f"Error executing cURL command: {e}")

*************************************

Error

Error executing cURL command

'--data-raw', '{"data": [{"symbol": "NSE:BANKNIFTY23O0443000CE", "qty": 15, "side": -1, "type": 2, "productType": "CNC", "limitPrice": 0.0, "stopLoss": 0.0}, {"symbol": "NSE:BANKNIFTY23O0443000PE", "qty": 15, "side": -1, "type": 2, "productType": "CNC", "limitPrice": 0.0, "stopLoss": 0.0}]}']' returned non-zero exit status 3.

2 replies