# Error when placing an order in real account

**URL:** <https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142>\
**Category:** Community Support\
**Created:** [March 8, 2022, 5:40pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142 "2022-03-08T17:40:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustrom](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gustrom](https://community.tradovate.com/u/gustrom)\
**Post date:** [March 8, 2022, 5:40pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142/1 "2022-03-08T17:40:32Z")

</div>

Hello everyone,

I am able to place orders in both DEMO and Market Replay modes.

When I connect to the real account, I’m able to get an auth token, request market data and do syncRequests. However, every time I try to place an order I get the following error:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/9/9e86c99b7c7d9ffd9f5a208d0b7be412c5517703.png)

What do you suggest to fix it?

Thanks.

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 8, 2022, 6:42pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142/2 "2022-03-08T18:42:25Z")

</div>

Hello @gustrom,

Can you please share the request body?

---

<div class="post-metadata">

**Author:** ![gustrom](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gustrom](https://community.tradovate.com/u/gustrom)\
**Post date:** [March 8, 2022, 7:17pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142/3 "2022-03-08T19:17:02Z")

</div>

Sure thing

 ![body](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/9/9d5c850c93d6131c0d755e7b3fff212050f9114d.png)

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 9, 2022, 1:18pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142/4 "2022-03-09T13:18:35Z")

</div>

Are you using the same account ID for live and demo? There is a separate account for each environment, so the IDs will differ.

---

<div class="post-metadata">

**Author:** ![gustrom](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gustrom](https://community.tradovate.com/u/gustrom)\
**Post date:** [March 9, 2022, 1:56pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142/5 "2022-03-09T13:56:09Z")

</div>

For the Demo account the ID is different, this is the request body for the demo:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/7/7c1bfb0df1fbb05bfa3477753da914964181173b.png)

I am using the tutorial files, which automatically store the account id and spec after each initial connection. In this case, the order went through with no issues.

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 9, 2022, 2:30pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142/6 "2022-03-09T14:30:12Z")

</div>

There should also be a text error accompanying the response. If you can log the message before it tries to decode it as JSON you should see raw text accompanying the error that should describe why it went wrong. It’s possible you don’t meet margin requirements, you may have a risk config on that account that prevents the order’s submission, or something to that effect (since its a 401 error).

Are you familiar with cURL? If you call this cURL and replace the angle bracketed parts with the values for your account it should return the text with the 401 response.

```auto
curl -X POST "https://live.tradovateapi.com/v1/order/placeorder" -H "accept: application/json" -H "Authorization: Bearer <token>" -H "Content-Type: application/json" -d "{\"accountSpec\":\"<accountSpec>\",\"accountId\":22423,\"action\":\"Buy\",\"symbol\":\"NQH2\",\"orderQty\":1,\"orderType\":\"Limit\",\"price\":13000,\"isAutomated\":true}" 

```

---

<div class="post-metadata">

**Author:** ![gustrom](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gustrom](https://community.tradovate.com/u/gustrom)\
**Post date:** [March 9, 2022, 5:29pm UTC](https://community.tradovate.com/t/error-when-placing-an-order-in-real-account/4142/8 "2022-03-09T17:29:59Z")

</div>

I’ve finally fixed my issue, as @EOD_Trader said in his post…

[https://community.tradovate.com/t/401-access-denied-in-order-placeorder/3650/8](https://community.tradovate.com/t/401-access-denied-in-order-placeorder/3650/8)

When using the real account, it seems to be mandatory to include the deviceId field in the login credentials if orders are to be placed.

Later I found that the deviceId can be directly located in the Tradovate platform, when clicking Curl in the API keys configuration.

Thanks for your support.
