Unable to Place Order from Python UpLinkV2 API

I am not sure what’s wrong with this.


def PlaceUPSTOXOptionBuyLIMITOrder(userid,quantity, price, tag, instrument_token):
    try:
        url = "https://api.upstox.com/v2/order/place"

        payload={        
                    "quantity": quantity,
                    "product": "I",
                    "validity": "DAY",
                    "price": price,
                    "tag": tag,
                    "instrument_token": instrument_token,
                    "order_type": 'LIMIT',
                    "transaction_type": "BUY",
                    "disclosed_quantity": 0,
                    "trigger_price": price - 0.10,
                    "is_amo": False
                }
        
        headers = {
        'Authorization': 'Bearer ' + accessToken,
        'Content-Type': 'application/json',
        'Accept': 'application/json'
        }
        print(payload)
        response = requests.request("POST", url, headers=headers, data=str(payload).replace("'","'"))
        
        #Parse Json Reponse
        status, orderid =  ParseOrderResponse(response.text)
        if status == 'success':
            SaveResponse(pos_order_id=orderid, pos_jsonResponse=response,identifier=tag, userid=userid)

        print(response.text)
    except Exception as e:
        print(f"PlaceUPSTOXOptionBuyLIMITOrder : {e}")

payload: {‘quantity’: 15, ‘product’: ‘I’, ‘validity’: ‘DAY’, ‘price’: 140.0, ‘tag’: ‘1980307081|23120’, ‘instrument_token’: ‘BSE_FO|881325’, ‘order_type’: ‘LIMIT’, ‘transaction_type’: ‘BUY’, ‘disclosed_quantity’: 0, ‘trigger_price’: 140.1, ‘is_amo’: False}

ERROR:
{“status”:“error”,“errors”:[{“errorCode”:“UDAPI100038”,“message”:“Invalid input passed to the API”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100038”,“property_path”:null,“invalid_value”:null}]}

Even I tried with this json instead of data.

def PlaceUPSTOXOptionBuyLIMITOrder(userid,quantity, price, tag, instrument_token):
    try:
        url = "https://api.upstox.com/v2/order/place"

        payload={        
                    "quantity": quantity,
                    "product": "I",
                    "validity": "DAY",
                    "price": price,
                    "tag": tag,
                    "instrument_token": instrument_token,
                    "order_type": 'LIMIT',
                    "transaction_type": "BUY",
                    "disclosed_quantity": 0,
                    "trigger_price": price - 0.10,
                    "is_amo": False
                }
        
        headers = {
        'Authorization': 'Bearer ' + accessToken,
        'Content-Type': 'application/json',
        'Accept': 'application/json'
        }
        print(payload)
        response = requests.request("POST", url, headers=headers, json=payload)
        
        #Parse Json Reponse
        status, orderid =  ParseOrderResponse(response.text)
        if status == 'success':
            SaveResponse(pos_order_id=orderid, pos_jsonResponse=response,identifier=tag, userid=userid)

        print(response.text)
    except Exception as e:
        print(f"PlaceUPSTOXOptionBuyLIMITOrder : {e}")

same issue.

{‘quantity’: 15, ‘product’: ‘I’, ‘validity’: ‘DAY’, ‘price’: 140.0, ‘tag’: ‘1980307081|23120’, ‘instrument_token’: ‘BSE_FO|881325’, ‘order_type’: ‘LIMIT’, ‘transaction_type’: ‘BUY’, ‘disclosed_quantity’: 0, ‘trigger_price’: 139.9, ‘is_amo’: False}

error
{“status”:“error”,“errors”:[{“errorCode”:“UDAPI100011”,“message”:“Invalid Instrument key”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100011”,“property_path”:null,“invalid_value”:null}]}

Thanks
R C Vamsi Vardhan

I believe the issue is resolved. At this point, we cannot place Intraday Orders in BSE as mentioned in this topic. Intraday Orders Not Allowed In BSE FO Segment

Thanks & Regards
R C Vamsi Vardhan

Yes, you are right.