Having trouble creating a webhook

I get som errors, when i try to flash my code to the cloud. I have tried to follow the Docs, I must be doing some noom mistake. :confused:

Errors i get:

bool CloudClass::subscribe(const char*, EventHandler)' is deprecated: Beginning with 0.8.0 release, Particle.subscribe() will require event scope to be specified explicitly. Define PARTICLE_USING_DEPRECATED_API macro to avoid this warning. [-Wdeprecated-declarations]
     Particle.subscribe("hook-response/get_city_weather", weatherForecast );
/wiring/inc/spark_wiring_cloud.h:499:13: note: declared here
 inline bool CloudClass::subscribe(const char* name, EventHandler handler) {
particle::Future<bool> CloudClass::publish(const char*)' is deprecated: Beginning with 0.8.0 release, Particle.publish() will require event scope to be specified explicitly. Define PARTICLE_USING_DEPRECATED_API macro to avoid this warning. [-Wdeprecated-declarations]
converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'
     return NULL;

I followed this tut:

And this:

Although the error message is moot now (as there is no PUBLIC/ALL_DEVICES scope anymore) this error message asks you to provide a scope parameter like this

Particle.subscribe("hook-response/get_city_weather", weatherForecast, MY_DEVICES);
Particle.publish("get_city_weather", PRIVATE);

All syntax version for that command can be found here


However, deprecation warnings wouldn't block your code from building anyway.

That part was confusing. Is that the name of the device?

This is the url am using:

 warning: passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]
     return NULL;
'bool CloudClass::subscribe(const char*, EventHandler)' is deprecated: Beginning with 0.8.0 release, Particle.subscribe() will require event scope to be specified explicitly. Define PARTICLE_USING_DEPRECATED_API macro to avoid this warning.

I think this is the main errors.

Particle.publish("get_min_weather", PRIVATE);
Particle.subscribe("hook-response/get_min_weather", weatherForecast);

This stands for all your devices (including API events sent by the cloud for your devices).

it works now, but the data is coming as null and i get all the info on the site even the html. what size kan i use for global weather api? cause i think my url is getting me far off where i want to be.

To answer that in any meaningful way we would need a lot more info.

  • how are you triggering the webhook?
  • how is the webhook defined (completely)?
  • what do you see as in the webhook log (console.particle.io/integrations)?
  • the more info you provide (without us needing to request it) the better we will be able to help.
 void loop () {
  Serial.println("Request Weather....");

[quote="ScruffR, post:7, topic:58650"]
what do you see as in the webhook log ([console.particle.io/integrations ](http://console.particle.io/integrations))?


 void setup () {
  Particle.subscribe("hook-response/get_min_weather", handleForecastReceived, MY_DEVICES);

// Gets called when weather data is ready
void weatherForecast(const char *event, const char *data) {

String str = String(data);

String locationStr = tryExtractingString(str, "<location>", "</location>");
String weatherStr = tryExtractingString(str, "<weather>", "</weather>");
String tempratureStr = tryExtractingString(str, "<temprature_c>", "</temprature_c>");
String windStr = tryExtractingString(str, "<wind_string>", "</wind_string>");

if(locationStr != NULL) {
  tft.print("At Location: " + locationStr);

if(weatherStr != NULL) {
  tft.print("The weather is: " + weatherStr);

if(tempratureStr != NULL) {
  tft.print("The temprature is: " + tempratureStr + String(" *C"));

if(windStr != NULL) {
  tft.print("The wind is: " + windStr);


// Text that is found between start and end will be returned in str 
// Ex: startbarend -> bar
String tryExtractingString(String str, const char* start, const char* end) {
  if (str == NULL) {
    return NULL;

  int idx = str.indexOf(start);
  if (idx < 0) {
    return NULL;

  int endIdx = str.indexOf(end);
  if (endIdx < 0) {
    return NULL;
  return str.substring(idx + strlen(start), endIdx);
void getData()
	// Publish an event to trigger the webhook
// Som random 40.4406,-79.9959
  Particle.publish("forecast", "40.4406,-79.9959", PRIVATE);
............... <--- I am just hiding it, but its in there
December 3rd, 2020
Event Name
The Particle event name that triggers the webhook

Full URL
The target endpoint that is hit when the webhook is triggered

Request Type
The standard web request method used when the webhook is triggered

Request Format
How the webhook data will be encoded and passed to the target endpoint

Query Parameters
Query Parameters
Parameters to append the URL string when hitting the webhook endpoint


  "event": "{{{PARTICLE_EVENT_NAME}}}",
  "data": "{{{PARTICLE_EVENT_VALUE}}}",
  "coreid": "{{{PARTICLE_DEVICE_ID}}}",
  "published_at": "{{{PARTICLE_PUBLISHED_AT}}}"

Enforce SSL
Whether your webhook will will validate the certificate against its certificate authority chain

Trigger Integration
Put this code in your firmware to trigger this integration Docs


void loop() {
  // Get some data
  String data = String(10);
  // Trigger the integration
  Particle.publish("get_min_weather", data, PRIVATE);
  // Wait 60 seconds

Get Integration Response
Put this code in your firmware to get a response from this integration Docs


void setup() {
  // Subscribe to the integration response event
  Particle.subscribe("hook-response/get_min_weather", myHandler, MY_DEVICES);

void myHandler(const char *event, const char *data) {
  // Handle the integration response


Can you check your post after you submitted it? There are some portions that are definitely not looking right :wink:

In order to provide your webhook definition the easiest way would be to

Since the response of the darksky server is not very suitable for IoT consumption you will have to filter through multiple responses (each max ~600 bytes) to find the data you are looking for. You may even have to stitch together multiple responses as the desired payload may be broken up over two separate chunks.

BTW, you have the location hard coded in your webhook, hence the coordinates you post in your "forecast" event wouldn’t be affecting the outcome.

And finally, when you check the data your browser gets from https://darksky.net/forecast/59.9116,10.7334/si12/en you will see that the strings you are looking for via tryExtractingString() are not even in that response.

AFAICT DarkSky is dead for independent IoT consumption since they were consumed by Apple.

I see, does it exists a another site that i can use?

That gives me weather, wind, temprature and location?

Thank you in advance!

I’m using OpenWeatherMap but there are many others.
You’d need to search the web for the best one around your area.

Isnt OpenWeatherMap global?

What do you mean?
Sure it is global that means it also covers your location, wouldn’t it?

Yes, i mean if it gives weather data for the world

How can i find out what i need ?

Based on what i want.

I created a new webhook to openweatherapi. I visit the url. Where from there can i find what i need to feed my program ?

You can try searching the forum as this question has come up and been answered before :wink:

* Humidity:82%
* Dew point:-2°C
* Visibility:0.2km

Will i feed my weatherForcast function:

etc ?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.