# 400 error bad request when placing orders

**URL:** <https://community.tradovate.com/t/400-error-bad-request-when-placing-orders/6622>\
**Category:** Community Support\
**Created:** [February 7, 2023, 12:44am UTC](https://community.tradovate.com/t/400-error-bad-request-when-placing-orders/6622 "2023-02-07T00:44:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Holmes](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@Jon\_Holmes](https://community.tradovate.com/u/Jon_Holmes)\
**Post date:** [February 7, 2023, 12:44am UTC](https://community.tradovate.com/t/400-error-bad-request-when-placing-orders/6622/1 "2023-02-07T00:44:10Z")

</div>

Hello everyone, whenever I try to place an order by sending a post request to [https://demo.tradovateapi.com/v1/order/placeorder](https://demo.tradovateapi.com/v1/order/placeorder) I get a 400 error “bad request.” I also see that the response says { violations: [array] }. My access token was just refreshed before running the program and has worked with other endpoints. My request snippet is below along with some screenshots. Please advise. Any assistance is appreciated.

```auto
    let params = {
        "accountId": CENSORED,
        "action": "Buy",
        "symbol": "RTYH3",
        "orderQty": 1,
        "orderType": "TrailingStop",
        "timeInForce": "GTC",
        "isAutomated": true
    }

    axios.post("https://demo.tradovateapi.com/v1/order/placeorder", params ,{
        headers: {
            "Authorization": `Bearer ${accessToken}`,
            "Content-Type": "application/json"
        }
    }).then(function (response) {
        console.log(response);
    }).catch(function (error) {
        console.log(error);
    });

```

![image](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/b/b153cb2bf99b74451ae40b526ebf31f59bd5a986.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/e/ebff84717037d3abe6c1702fce024711a275f948.png)

---

<div class="post-metadata">

**Author:** ![Jon\_Holmes](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@Jon\_Holmes](https://community.tradovate.com/u/Jon_Holmes)\
**Post date:** [February 7, 2023, 3:48pm UTC](https://community.tradovate.com/t/400-error-bad-request-when-placing-orders/6622/2 "2023-02-07T15:48:04Z")

</div>

Solved- for anyone who comes across this in the future, here’s my solution:

```auto
console.log("Buying long")
let stopPriceLong = XYZ
let params = {
    "accountSpec": "DEMO######",
    "accountId": ######,
    "action": "Buy",
    "symbol": "RTYH3",
    "orderQty": 1,
    "orderType": "TrailingStop",
    "stopPrice": stopPriceLong,
    "timeInForce": "GTC",
    "isAutomated": true
}

fetch('https://demo.tradovateapi.com/v1/order/placeorder', {
    method: 'POST',
         headers: {
             'Accept': 'application/json',
              'Authorization': `Bearer ${accessToken}`,
    },
    body: JSON.stringify(params)
}).then(res => res.json()).then((out) => {
    console.log(out)
}); 

```

The accountId is the Id field when you send a get request to [https://demo.tradovateapi.com/v1/account/list](https://demo.tradovateapi.com/v1/account/list) and the accountSpec is the name field. I hope this helps anyone who encounters a similar issue in the future.
