HTTP POST Header

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • Gast

    HTTP POST Header

    Hello,
    Does anyone know how we can control the header data of an HTTP POST virtual output command?

    Virtual Output - Address field contains; the hostname
    Virtual Output Command - Command for ON field contains; /restoftheTargetAPIURI
    Virtual Output Command - HTTP Post command for ON contains;
    Authorization: Bearer 6fd2c9f940c0f3243c3d1b3d1bb9e76\r
    Content-Type: application/json\r
    \r
    {"mode":"sync", "messageType":"0f8453105c3b9faf7886", "messages":[{"celcius":29.3, "humidity":59.9, "timestamp":"2017-01-15T11:55:37.930Z"}]}

    Anyone a better suggestion to be able to determine the header data?
    Thanks for your help!
  • Gast

    #2
    Put your HTTP headers into the "HTTP extensions for ON" field.
    Put the HTTP body into the "HTTP Post command for ON" field
    Make sure the HTTP method is set correctly - i.e. PUT/POST/GET

    Because there are multple headers, separate them with a "\r\n" - i.e instead of a single carriage-return, try using carriage-return followed by line-feed character. And you don't need the CR/LF at the end of the header field. Try doing this:

    HTTP extensions for ON:
    Authorization: Bearer 6fd2c9f940c0f3243c3d1b3d1bb9e76\r\nContent-Type: application/json

    HTTP Post command for ON:
    {"mode":"sync", "messageType":"0f8453105c3b9faf7886", "messages":[{"celcius":29.3, "humidity":59.9, "timestamp":"2017-01-15T11:55:37.930Z"}]}

    Command for ON:
    /restoftheTargetAPIURI

    Kommentar

    • erstoner
      Azubi
      • 25.07.2019
      • 2

      #3
      This post has been very helpful for me. Is it possible to include variables in the HTTP Post command? For example:

      HTTP Post command for ON:
      {"mode": "sync", "messageType": "0f8453105c3b9faf7886", "messages": [{"celcius": X, "humidity": 59.9, "timestamp": "2017-01-15T11: 55: 37.930Z"}]}

      wherein X is a value generated by some input function (for example virtual input slider).

      Thank you!

      Kommentar

      • Tico
        Lox Guru
        • 31.08.2016
        • 1030

        #4
        Yes, you should be able to.

        Where X is indicated, replace with <v>. The analogue value is fed into the Virtual Output and on each value change, the POST command will be sent. Uncheck 'Use as digital output'. Unit should be <v>.

        If this doesn't work, you might need to compose the full text string in a Status Block. An example is attached.
        Ich spreche kein Deutsch. Gib Google Translate die Schuld, wenn ich unverständlich bin.

        Kommentar

        • erstoner
          Azubi
          • 25.07.2019
          • 2

          #5
          Zitat von Tico
          Where X is indicated, replace with <v>. The analogue value is fed into the Virtual Output and on each value change, the POST command will be sent. Uncheck 'Use as digital output'. Unit should be <v>.
          This worked perfectly without needing to compose in a Status Block.

          👍👍👍

          Kommentar

          • Gillisk87
            Azubi
            • 26.11.2022
            • 1

            #6
            I am trying to control rgb lights that are implemented in home assistant from Loxone.
            I have already managed to control them with a fixed color.
            Now I am trying to do this with variable text using an rgb lighting controller.
            If I enter the following at http body for on it does not work. How do I make sure that it correctly retrieves the v1, v2, v3?

            HTTP body by on:

            {
            "entity_id": "light.staanlamp_licht",
            "rgb_color": [<v1>, <v2>, <v3>],
            "brightness": 255
            }
            Angehängte Dateien

            Kommentar

            • Jan W.
              Lox Guru
              • 30.08.2015
              • 1208

              #7
              I don't think that you have three inputs on an HTTP virtual output. I recommend to use a status block to combine the three input values, maybe the whole HTTP body and forward that output to the http virtual output by using <v> in the body or the square brackets from your example.
              Miniserver v14.5.12.7, 2x Ext., 2x Relay Ext., 2x Dimmer Ext., DMX Ext., 1-Wire Ext., Gira KNX Tastsensor 3 Komfort, Gira KNX Präsenzmelder, Fenster- und Türkontakte, Loxone Regen- und Windsensor, Gira Dual Q Rauchmelder vernetzt, 1x Relais-Modul
              Loxberry: SmartMeter, MS Backup, CamConnect, Weather4Lox
              Lüftung: Helios KWL EC 370W ET mit Modbus TCP - via Pico-C
              Heizung: Stiebel Eltron WPF 5 cool (Sole-Wasser WP) mit ISG, FB-Heizung mit 18 Kreisen, Erdsonde - via modbus/TCP
              Node-RED: IKEA Tradfri

              Kommentar


              • Gillisk87
                Gillisk87 kommentierte
                Kommentar bearbeiten
                Thanks worked perfectly!
            Lädt...