Supereg / homebridge-http-switch

Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
ISC License
218 stars 36 forks source link

Trouble with sending json Body #95

Closed mbierman closed 2 years ago

mbierman commented 2 years ago

Describe the bug I am having trouble sending a body in my URL request. I may be doing it wrong and perhaps this is just a request for better documentation.

Expected behavior I want to send JSON with my URL

To Reproduce Steps to reproduce the behavior:

  1. Use the following configuratoin.
  2. Trigger the resulting switch.
  3. Nothing happens (The webhook does not trigger).
{
    "accessory": "HTTP-SWITCH",
    "name": "Printer Off Alert",
    "serialNumber": "SW007",
    "switchType": "stateless",
    "timeout": 1000,
    "onUrl": "https://maker.ifttt.com/trigger/homealert/json/with/key/***",
    "method": "POST",
    "headers": {
        "Content-Type": "application/json"
    },
    "body": {
        "value1": "Printer turned off",
        "value2": "",
        "value3": "https://cdn6.aptoide.com/imgs/6/b/8/6b80c88a03910f16ea0c7cf062952174_icon.png?w=256"
    }
}

The following does work but I would love to use the simpler unencoded format.

 {
    "accessory": "HTTP-SWITCH",
    "name": "Printer Off Alert",
    "serialNumber": "SW007",
    "switchType": "stateless",
    "timeout": 1000,
    "onUrl": "https://maker.ifttt.com/trigger/homealert/with/key/***?value1=%F0%9F%96%A8%20Printer%20turned%20off%20%F0%9F%96%A8&value2=&value3=https%3A%2F%2Fcdn6.aptoide.com%2Fimgs%2F6%2Fb%2F8%2F6b80c88a03910f16ea0c7cf062952174_icon.png%3Fw%3D256",
    "method": "POST"
   }

Version (output of npm list -g homebridge homebridge-http-switch) image

Configuration

see above.

Additional context Add any other context about the problem here.