Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending JSON body #103

Closed
mbierman opened this issue Dec 21, 2021 · 2 comments
Closed

Sending JSON body #103

mbierman opened this issue Dec 21, 2021 · 2 comments

Comments

@mbierman
Copy link

mbierman commented Dec 21, 2021

Is your feature request related to a problem? Please describe.
I'm trying to post a JSON payload and it isn't working. This might not be a bug,just a documentation issue (no example provided).

{
            "accessory": "HTTP-SWITCH",
            "name": "NAS temp warning",
            "switchType": "stateless",
            "serialNumber": "SW002",
            "timeout": 1000,
            "onUrl": "https://maker.ifttt.com/trigger/homealert/with/key/d16qe9xyq1***SVS",
            "body": {
                "value1": "NAS is running hot",
                "value2": "temperature is over 95",
                "value3": "https://i.ibb.co/28HTMY7/Unknown.png"
            },
            "method": "POST",
            "debug": false
        },

What am I doing wrong?

I'm also confused by this:

Defines the body sent with the http request. If value is not a string it will be converted to a JSON string automatically.

Is it meant to say?

Defines the body sent with the http request. If value is a string it will be converted to a JSON string automatically.

Describe the solution you'd like

Additional context
Add any other context about the feature request here.

@mbierman mbierman changed the title Sending encoded URLs Sending JSON body Dec 21, 2021
@mbierman
Copy link
Author

mbierman commented Dec 22, 2021

o.k. I figured out the issue. The documentation should be enhanced with better examples IMHO since I am not the only one who has had issues with this. For the sake of others in the future (including myself if I forget) here's a proper example:

   {
            "accessory": "HTTP-SWITCH",
            "name": "NAS temp warning",
            "switchType": "stateless",
            "serialNumber": "SW002",
            "timeout": 1000,
            "debug": true,
            "method": "POST",
            "headers": {
                "Content-Type": "application/json"
            },
            "onUrl": {
                "url": "https://maker.ifttt.com/trigger/homealert/with/key/***",
                "method": "POST",
                "headers": {
                    "Content-Type": "application/json"
                },
                "body": {
                    "value1": "🔥  NAS is running hot 🔥",
                    "value2": "temperature is over 95",
                    "value3": "https://sflanders.net/wp-content/uploads/2015/11/synology-150x150.png"
                }
            }
        },

@Supereg
Copy link
Owner

Supereg commented Feb 16, 2023

@Supereg Supereg closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants