# MQTT engine.publish can't write tag and Sparkplug Decoder show "Failed to parse the payload"

**URL:** <https://forum.inductiveautomation.com/t/mqtt-engine-publish-cant-write-tag-and-sparkplug-decoder-show-failed-to-parse-the-payload/63085>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [August 17, 2022, 1:38am UTC](https://forum.inductiveautomation.com/t/mqtt-engine-publish-cant-write-tag-and-sparkplug-decoder-show-failed-to-parse-the-payload/63085 "2022-08-17T01:38:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pofer\_Wang](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@Pofer\_Wang](https://forum.inductiveautomation.com/u/Pofer_Wang)\
**Post date:** [August 17, 2022, 1:38am UTC](https://forum.inductiveautomation.com/t/mqtt-engine-publish-cant-write-tag-and-sparkplug-decoder-show-failed-to-parse-the-payload/63085/1 "2022-08-17T01:38:20Z")

</div>

Hello everyone

I want to use ‘system.cirruslink.engine.publish’ script write MQTT tag  
but it can’t run

my script:

```auto
server = 'Chariot SCADA'
topic = 'spBv1.0/IgnitionMQTT/DCMD/test/test'

today = system.date.now()
next = system.date.setTime(system.date.getDate(1970, 0, 1), 8, 0, 0)

timestamp = str(system.date.millisBetween(next,today))

payload = '{"timestamp":' + timestamp +',"metrics":[{"name":"ClientEvent/WindowChangeSec","timestamp":' + timestamp +',"dataType":"Int32","value":15}],"seq":0}'

system.cirruslink.engine.publish(server, topic, str(payload).encode(), 0, 0)

```

I use MQTTfx check.  
My “Sparkplug Decoder” show “Filed to parse the payload”

 ![2022-08-17 09_37_16-Window](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/c/ac535f2fe0fe4489e6f30b87c274aad4b6c90714.png)

but “Plain Text Decoder” show my payload is correct

 ![3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/8/a82d39c987af42423ba128d4ebd7aebb5d757bb1.png)

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [August 17, 2022, 3:28am UTC](https://forum.inductiveautomation.com/t/mqtt-engine-publish-cant-write-tag-and-sparkplug-decoder-show-failed-to-parse-the-payload/63085/2 "2022-08-17T03:28:47Z")

</div>

Sparkplug B messages are encoded using Google Protocol Buffers (see section 4.3 of the [Sparkplug specification](https://www.eclipse.org/tahu/spec/Sparkplug%20Topic%20Namespace%20and%20State%20ManagementV2.2-with%20appendix%20B%20format%20-%20Eclipse.pdf)); you won’t be able to write straight JSON payloads by default. Is there a reason why you can’t just bring the group/node/device in via MQTT Engine and then just write to the tag (which would then propagate the write via a DCMD message through MQTT/Sparkplug)?

---

<div class="post-metadata">

**Author:** ![Pofer\_Wang](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@Pofer\_Wang](https://forum.inductiveautomation.com/u/Pofer_Wang)\
**Post date:** [August 17, 2022, 8:05am UTC](https://forum.inductiveautomation.com/t/mqtt-engine-publish-cant-write-tag-and-sparkplug-decoder-show-failed-to-parse-the-payload/63085/3 "2022-08-17T08:05:45Z")

</div>

Becouse I have a hardware gateway have MQTT Publish able.  
I can use it publish to Ignition distributor.  
It read tag correct.  
but I can’t write the tag.

I check MQTTfx it sparkplug Decoder  
it like this

 ![2022-08-17 16_00_56-Server2016_ignition - VMware Workstation](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/74d1484f701c98ac69f1991d1a7f0409efe2eb21.png)

I don’t know why name is none

so I try the function.
