Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
When I am trying to publish a simulator tag value to a broker I am facing the below error. Can someone tell me how to fix the error
MQTT agent 'MQTT Broker' failed to process write request on topic '123' - reason: 'Cannot deserialize value of type `[Lcom.kepware.agents.mqtt.WriteValue;` from Object value (token `JsonToken.START_OBJECT`)_ at [Source: (String)"{"timestamp":1704956770208,"values":[{"id":"Simulator.Long.Rand","v":49,"q":true,"t":1704956770198}]}"; line: 1, column: 1]'
Adjust the JSON payload to match the expected format as described as below
Write formatting To perform a write, the data needs to be in the following format:
[{"id": "Channel1.Device1.Tag1","v": 42},{"id": "Channel1.Device1.Tag2","v": 523}]
The “Channel1.Device1.Tag1” should be replaced by the tag to be written and “42” by the value to be written.
The example above shows a JSON array that should update both Tag1 and Tag2 when parsed by the MQTT agent.
Using Mosquitto_sub.exe to update Tag1 from a DOScommand line would look like: mosquitto_pub.exe -t iotgateway/write -m "[{\"id\": \"Channel1.Device1.Tag1\",\"v\": 42}]"
Note
The MQTT agent checks the topic specified for JSON data in the proper format. Once the agent parses the data, it attempts to write the value to the specified tag.
Only tags that have been added to the MQTT agent may be written.