wysyłanie powiadomień z Node-RED przez API

User avatar
lukfud
Posts: 2190
Joined: Thu Nov 23, 2017 11:33 pm
Location: Warszawa

Post

Cześć,

Nie potrafię ustawić "http request" noda, aby wysłać wiadomość.
Metoda: HEAD, url wpisany, nagłówki: Accept, Authorization i Content-Type doadne.
Nie wiem jak przekazać wiadomość:

Code: Select all

{
    "title": "Node-red",
    "body": "test",
    "accessIds": [
        YYYY
    ]
}
-------------
Jednak potrafię :) Poniżej wyeksportowane nody. Należy wpisać swój ID, token dostępowy i adres serwera.

Code: Select all

[
    {
        "id": "c6f3d0eafa92cb0e",
        "type": "http request",
        "z": "65871f77d7c44ba0",
        "name": "request",
        "method": "use",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://svr30.supla.org/api/v3/notifications",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 380,
        "y": 400,
        "wires": [
            [
                "0e85c3cd857a8b86"
            ]
        ]
    },
    {
        "id": "8d4e8e4e43bef5dd",
        "type": "inject",
        "z": "65871f77d7c44ba0",
        "name": "inject",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 110,
        "y": 400,
        "wires": [
            [
                "6537b31b905ebd3c"
            ]
        ]
    },
    {
        "id": "0e85c3cd857a8b86",
        "type": "debug",
        "z": "65871f77d7c44ba0",
        "name": "debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 510,
        "y": 400,
        "wires": []
    },
    {
        "id": "6537b31b905ebd3c",
        "type": "function",
        "z": "65871f77d7c44ba0",
        "name": "function",
        "func": "msg.payload = {\n    \"title\":\"Node-red\",\n    \"body\":\"test\",\n    \"accessIds\":[\n        -> ID_użytkownika <-\n    ]\n}\nmsg.method = \"PATCH\"\nmsg.headers = {\n    \"accept\": \"*/*\",\n    \"Authorization\": \"Bearer -> osobisty_token_dostępowy <- \",\n    \"Content-Type\": \"application/json\"\n}\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 240,
        "y": 400,
        "wires": [
            [
                "c6f3d0eafa92cb0e"
            ]
        ]
    }
]
https://www.facebook.com/groups/supladiy/

Return to “FAQ / Jak to zrobić”