Console webhook editor improvements

Hi everyone,

I wanted to share some improvements to the webhook editor that just went live on the Console.

There is now an explicit Request Format dropdown to select between Web Form, JSON and Custom Body for sending the data in POST, PUT and DELETE requests. For GET request, the request format is Query Parameters.

If you want to customize the fields sent in the webhook, you will now be shown the default fields. You can chose to add additional fields below the default fields, or send only your custom fields.

For JSON webhooks, you can also pick the default fields or define your own template.


You can now send JSON data that is not a string by skipping the quotes in the JSON editor. An X will appear saying the JSON is not valid, so it’s up to you to make sure that whatever data you publish from your event will end up making the JSON valid. In the example below, publishing an event with an integer or floating point number would work.

Finally, the Custom Template tab now synchronizes with the Webhook Builder. You can make changes to either and switch back and forth to see the effects. Refer to the webhook template reference when making changes in the Custom Template tab.

Things that have not changed:

  • You can use the predefined variables like {{PARTICLE_EVENT_NAME}} and {{PARTICLE_EVENT_VALUE}} in any field of your webhook template, including on the left or right hand side of the Web Form, Query Parameters and Headers field lists.
  • If the data you publish from your firmware is in JSON format, you can use the JSON fields in any field of your webhook template. For example, Particle.publish("status", "{\"result\": \"ok\"}", PRIVATE); would allow you to use {{result}} in your webhook template.

The Particle webhook guide is updated with the new UI.

Enjoy the new usability in creating webhooks!

7 Likes

One of the most common types of problem encountered in this community forums is code becoming unresponsive due to the use of String variables particularly in relation to Particle.publish events. Perhaps this will help but only if the docs back it up.

In the webhook example in the documentation this line appears:

String temp = String(random(60, 80));

which is bad

When the advice on here would instead to use

char status[255];
  snprintf(status,sizeof(status),"Temp:%i  ",random(60, 80));
Particle.publish("Pumps",status,PRIVATE);

In addition there is a very extensive section in the docs on working with strings in C++, all very confusing to the noob.

2 Likes