thingsboard-gateway icon indicating copy to clipboard operation
thingsboard-gateway copied to clipboard

[HELP] REST Connector JSON Downlink Converter not able to send JSON?

Open apachler opened this issue 10 months ago • 1 comments

Describe the issue I try to POST a request to an REST API endpoint if an shared attribute updates on a device. The attribute is a Boolean value with the key occupation . It seems that the default Json Downlink Converter does not correctly convert the payload, its result is the following

'{"sampleDeviceName": True}'

Do i miss something or is this a bug?

Configuration

  "attributeUpdates": [
    {
      "HTTPMethod": "POST",
      "SSLVerify": false,
      "httpHeaders": {
        "CONTENT-TYPE": "application/json"
      },
      "security": {
        "type": "anonymous",
        "username": "user",
        "password": "passwd"
      },
      "timeout": 0.5,
      "tries": 3,
      "allowRedirects": true,
      "deviceNameFilter": ".*",
      "attributeFilter": "occupation",
      "requestUrlExpression": "http://sample-rest-endpoint-host/${attributeKey}",
      "valueExpression": "{\"${deviceName}\": ${attributeValue}}"
    }
  ],

Connector name (If you need help with some connector/converter): REST Connector

Versions (please complete the following information):

  • OS: SLES15
  • Thingsboard IoT Gateway version 3.5.2
  • Python version 3.9

apachler avatar Feb 21 '25 10:02 apachler

Is seems adding

            result["data"] = dumps(ast.literal_eval(result["data"]))

to the downlink converter before returning the result fixes this...

apachler avatar Feb 21 '25 11:02 apachler