christianTF / LoxBerry-Plugin-MQTT-Gateway

Subscribes to MQTT topics and relays to Miniserver
https://www.loxwiki.eu/display/LOXBERRY/MQTT+Gateway
12 stars 3 forks source link

Post Receiver: JSON Payload is not expanded #92

Closed christianTF closed 3 years ago

christianTF commented 3 years ago

The code checks for json and inserts the plain json into a json string. As the script. itself wraps the content into a json, the plugin only expands the outside json, but not the json wrapped into a string.

The json payload needs to be parsed in the php script and added as object to the json sent to the Gateway.

image

christianTF commented 3 years ago

The function of receive.php was correctly - json data are expanded as expected.

The special issue arised with the PLEX webhook, that does not send application/json but multipart/form-data, and submits a file (picture) as well as a POST form, where a field is called payload, that included the json.

Therefore, the script did not see a json content (as it is multipart content), and the post variable payload is sent as string to the gateway.

Although time consuming, I now also check the post variables if there content might be a json, and add parsed json also to post variables. https://github.com/christianTF/LoxBerry-Plugin-MQTT-Gateway/commit/b324df83f431304f112112a8e836cc44db620b10