Webhook with multiple parameters from electron

[UPDATE: I have been able to get further - see 2nd post in change]

I’m trying to create a webhook to send to Scriptr. The code I have that currently works via Wifi on ESP8266’s and ESP32’s is doing a direct POST to Scriptr and sends:

   /RV1Startup/?type=init&temp=[78.9,81.2]&interval=5&gps=[38.12345,78.98765]

Ignore the /RV1Startup/ - that just tells Scriptr which script to run - and that’s working.

I am able to create the webhook and get past the “authorization” at Scriptr. I tried reformatting into a format such as the following and passing it as the data string on the publish:

    “init”:[“init”],”temp”:[“78.9,81.2”],“interval”:[“5”],”gps”:[“38.12345,78.98765”]

Since that’s what Scriptr sees from a POST from my working ESP8266 module.

But passing quotes, equal signs, etc. get corrupted and it isn’t really being passed as a set of parameters.

In reading some of the forum posts, I see that using Mustache might work for me, but I’m confused as to what to pass as the data string and what the enter in the webhook setup.

Would I send the following string as data on the publish:

{“type”:”init”,”temp”:[78.9,81.2],”interval”:5,”gps”:[38.12345,78.98765] }

If so, do I need the opening and closing {} and also do I need to create the string using \” for the quotes in the firmware code?

Then, what do I enter where in the webhook? Do I create several parameters on separate lines in a “form” entry in the webhook definition:

type {{type}}
temp {{temp}}
interval {{interval}}
gps {{gps}}

Or do I enter a string like the following in a “JSON” type entry in the webhook definition?

{“type”:{{type}}, “temp”:[{{temp}}], “interval”:{{interval}}, “gps”:{{gps}} }

Scriptr expects Content-type: application/x-www-form-urlencoded

Will this send that way or send as JSON – and does it matter?

Thanks for any assistance – I’m very close to completing the cutover from running on ESP8266/ESP32 using Wifi to the Electron. I thought I was pretty much there once I was successfully able to get the webhook to fire, but now I’m stuck on formatting the data.

Thanks again.

OK, so I was able to get further along - much further. I am using the “form” type of webhook and went with the individual variables. And have been able to pass them.

Next question:

Suppose one of the variables doesn’t need to be passed via Publish. How can I get the webhook not to send a null value for it (that is, I don’t want it to send anything for the variable or value)?

I don’t think you can omit fields when using form mode.

In JSON mode, you can, using conditional blocks.

For example, {{#b}} marks the beginning on a test for b. If b exists, then the template up to {{/b}} is rendered. If b does not exist, then that part is skipped so nothing will be generated.

OK, thank you. For now I will update the Scriptr end to screen for empty parameters.