# MQTT publishing error

**URL:** <https://forums.losant.com/t/mqtt-publishing-error/1164>\
**Category:** Help\
**Created:** [October 5, 2018, 7:17pm UTC](https://forums.losant.com/t/mqtt-publishing-error/1164 "2018-10-05T19:17:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [October 5, 2018, 7:17pm UTC](https://forums.losant.com/t/mqtt-publishing-error/1164/1 "2018-10-05T19:17:18Z")

</div>

My device is connecting via MQTT, but I get the warning “Publish Error - Retain not allowed”

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 5, 2018, 7:20pm UTC](https://forums.losant.com/t/mqtt-publishing-error/1164/2 "2018-10-05T19:20:32Z")

</div>

Yes, we do not support retained messages when connecting to our broker. You can read more about this and other limitations in our [documentation](https://docs.losant.com/mqtt/overview/#mqtt-version-and-limitations).

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [October 5, 2018, 7:40pm UTC](https://forums.losant.com/t/mqtt-publishing-error/1164/3 "2018-10-05T19:40:17Z")

</div>

Ah, OK. Unfortunately I have no way of turning that off on my side.  
How can I post sensor data via API?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 5, 2018, 7:43pm UTC](https://forums.losant.com/t/mqtt-publishing-error/1164/4 "2018-10-05T19:43:29Z")

</div>

You can use the [Device: Send State](https://docs.losant.com/rest-api/device/#send-state) endpoint. You’ll want to [authenticate](https://docs.losant.com/rest-api/overview/#device-based-authentication) the request using an [application token](https://docs.losant.com/applications/application-tokens/).

Note, we do have [API clients](https://docs.losant.com/rest-api/overview/) in a few languages that might make this easier for you

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [October 5, 2018, 8:05pm UTC](https://forums.losant.com/t/mqtt-publishing-error/1164/5 "2018-10-05T20:05:24Z")

</div>

ok, I’m doing a POST http request from Node Red with like this:

```auto
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/state

```

but I get the response :

```auto
{"type":"Validation","message":"deviceState is required"}

```

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 5, 2018, 8:10pm UTC](https://forums.losant.com/t/mqtt-publishing-error/1164/6 "2018-10-05T20:10:44Z")

</div>

What does the body of your request look like? Sounds like it’s either malformed or not included at all.

Here’s an [example request body](https://docs.losant.com/rest-api/device/#request-body_2) you can check against.
