(SOLVED)Webhook To JSP (non JSON webhooks)

I have a Photon collecting power generation data from a solar array.
A website called PVOutput.Org has some free tools for logging via API.
They give some sample code for a POST request using cURL, like this:

curl -d "d=20111201" -d "t=10:00" -d "v1=1000" -d "v2=150" -H "X-Pvoutput-Apikey: Your-API-Key" -H "X-Pvoutput-SystemId: Your-System-Id" https://pvoutput.org/service/r2/addstatus.jsp

I've gotten pretty good at passing variables to forms and JSON formatted strings, but the trouble is I don't know how to create a webhook integration in the Particle console from the URL string above. Do I need to use Custom Body? Can I use webhooks or do I need the httpclient lib? I don't have to use headers for apikey and system ID. I can have those things in the body if I want with "key=yourapikey" or "sid=yoursysid."

Here is a partial list of parameters in a POST request.

Thanks!

I’m not sure on how to best send your data so somebody else will chime in on that but I do think the PVOutput website is pretty cool!

There are some pretty big solar arrays sending data to that site, the pictures of the actual solar arrays are neat to look at.

I was able to create webhooks properly using query parameters like this:

Method: GET
Headers:

{
"X-Pvoutput-Apikey": "myKey",
"X-Pvoutput-SystemId": "01010"
}

Query Parameters: (the 4 required are here)

{
"d": "{{Date}}",
"t": "{{Time}}",
"v2": "{{Watts}}",
"v1": "{{WattHrs}}"
}

After some debugging on Requestb.in it was determined that this should work and it did.
The GET request is then formed like this:

https://someurl.jsp?d={{Date}}&t={{Time}}&v2={{Watts}}&v1={{WattHrs}}

My publish string looks something like this:

Particle.publish("QHour", "{"Date":"" + strYear + strMonth + strDay + "", "Time":"" + Time.format(Time.now(), "%H:%M") + "",
"Volts":"" + String::format("%.2f",LineVoltage) + "", "Amps":"" + String::format("%.2f",LineCurrent) + "",
"Watts":"" + String::format("%.2f",RealPower) + "", "WattHrs":"" + String::format("%.2f",WattHrCount) + ""}", 60, PRIVATE);

This uses Mustache to dynamically pass variables to a webhook.
Notice that not all variables published to the cloud are passed to the webhook.

1 Like