[Solved] Webhook problem

Dear All,

I am trying to use webhook and I am not getting any response from the server in json, while the respons through a browser call is directly availble

What am I doing wrong. I tried the url from the doc page and that worked, but not with the 3rd party call I need.

The call is https://ttapp.nl/sbapi?getmatch&date=20151106&clubid=1358&matchnr=20108

Here is my code

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_MAX_READBYTES 1024
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxxx";
char pass[] = "xxxxxxxx";
// reference https://ttapp.nl/sbapi?getmatch&date=20151106&clubid=1358&matchnr=20108
int datum = 20151106;
int clubid=1358;
int matchnr= 20108;
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}
BLYNK_WRITE(V0){
  String webhookdata = param.asStr();
  Serial.println(webhookdata);
}
BLYNK_WRITE(V1){
  if (param.asInt() == 1) {
  Blynk.virtualWrite(V0,datum,clubid,matchnr);
  Serial.println(datum);
  Serial.println(clubid);
  Serial.println(matchnr);
  }
}

On Blynk I created a button with V1 connected and the webhook is on V0 with the following url
https://ttapp.nl/sbapi?getmatch&date=/pin[0]/&clubid=/pin[1]/&matchnr=/pin[2]/

The only feedback I am getting is the values in the serial.println but no webhookdata in json
I thought it might have to do with the buffer but that was not it.

Cheers Robert

Probably BLYNK_MAX_READBYTES 1024 is not enough. Please try to increase it.

I have increased it to 2048 but does not help

are you sure your url is correct in widget? Please double check.

Dear Dmitriy
I have typed the url 4 times new in the app and even dit only /pin/ and transferred from the hardware the link and it did not work
Any ideas?

Also do you trigger V1? Please show screenshot of url in widget.

I trigger V1 and then the connection/communication error and connection is established. But everytime I invoke V1 or V0 by button, this happens

What do you mean?

after invoking the button or blynk.virtualwrite, the communication with the blynk server is lost and reconnected (reset of connection)

@Robert_Holscher I see in log some api.sunrise-sunset.com requests. Is that from you?

No there is no wireing. It is the plain code and the webhook interface , no bells and whistles

@Robert_Holscher I see in log some api.sunrise-sunset.com requests. Is that from you?

Hi Dmitriy,

Yes that is from me, I was fiddling around and put .com behind is.
I have now directly in the webhook url the following
http://api.sunrise-sunset.org/json?lat=33.3823&lng=35.1856&date=2016-10-01

This is the example from your docs site.
I have constantly when I invoke the V0 that the device disconnects from Blynk and then comes back
Also I see in my serial monitor the 0 and 1 of the button response when I am putting the button on V0 as said in the doc, but that does not work well, when it returns a 0 and 1 , therefore I have put a Blynk.virtualwrite(V0,1) connected to the button, then it does not give the 1 and 0 as response.

I am not doing strange things here. My NodeMCU is the same one as I use for far more complex Blynk builds and there is nothing connected to it.
The problem is that I don’t see any warnings in my serial monitor, except that the device disconnects fro m Blynk when the webhook is activated

Look like mcu drops connection when it gets response from webhook. You have to find out why this happens. Does this example host works for you?

@Robert_Holscher the disconnect is because you have the readbytes in the wrong place. Must be before the Blynk libraries. json is approx 940 so 1024 is currently big enough.

All working here on my WeMos D1 Mini:

{"id":380876,"matchnr":20108,"datetime":"2015-11-06T19:00:00.000Z","matchtypeid":1,"teams":[{"id":1067751,"name":"DOV 4","teamplayers":[{"id":2137382,"name":"M. Petiet","subst":0},{"id":3294276,"name":"S. de Hoogt","subst":0},{"id":3413244,"name":"J. van der Aar","subst":0},{"id":3829013,"name":"D. Bendter","subst":0},{"id":4060662,"name":"R. Holscher","subst":0}],"matchplayers":[{"id":4060662,"name":"R. Holscher","dbl":1},{"id":3413244,"name":"J. van der Aar","dbl":1},{"id":3294276,"name":"S. de Hoogt","dbl":0}]},{"id":1067383,"name":"Stede Broec 5","teamplayers":[{"id":2220119,"name":"J. Broer","subst":0},{"id":3031636,"name":"R. Pronk","subst":0},{"id":3031644,"name":"J. Neuvel","subst":0},{"id":3033183,"name":"P. Sijm","subst":0},{"id":3293759,"name":"T. Buijsman","subst":0}],"matchplayers":[{"id":3293759,"name":"T. Buijsman","dbl":1},{"id":3033183,"name":"P. Sijm","dbl":1},{"id":3031644,"name":"J. Neuvel","dbl":0}]}]}

I am not getting the disconnect anymore, however also no response. With other links i am getting response. I dont know what you did differently.
The buffer define is now before libraries

@Robert_Holscher in webhook I am using GET with no body and the full url quoted incuding /pin[0]/, /pin[1]/ and /pin[2]. Do you have the button (V1) in Switch mode rather than Push mode (Switch for me)?

You can try increasing the baud rate from Blynk’s (old Arduino hardware) default of 9600 to a modern ESP of 115200.

If you are still struggling I’ll send my sketch but basically it’s the code you provided earlier in the thread.

Dear Costas, I will try with the higher baud rate and the push to switch and will let you know. Thanks for your help

Tried it with higher baudrate but still no luck. The call will not be returned with a json, I appreciate your code, maybe I am overlooking a typo.

// Webhook.ino by Costas 24 Dec 2016
#define BLYNK_MAX_READBYTES 1024
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[]   = "xxxx";
char ssid[]   = "xxxx";
char pass[]   = "xxxx";
char server[] = "blynk-cloud.com";
// reference https://ttapp.nl/sbapi?getmatch&date=20151106&clubid=1358&matchnr=20108
int datum = 20151106;
int clubid=1358;
int matchnr= 20108;

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, server);
}

void loop()
{
  Blynk.run();
}

BLYNK_WRITE(V0){
  String webhookdata = param.asStr();
  Serial.println(webhookdata);
}

BLYNK_WRITE(V1){
  if (param.asInt() == 1) {
    Blynk.virtualWrite(V0,datum,clubid,matchnr);
    Serial.println(datum);
    Serial.println(clubid);
    Serial.println(matchnr);
  }
}

Cut and paste of the url in Webhook is:

https://ttapp.nl/sbapi?getmatch&date=/pin[0]/&clubid=/pin[1]/&matchnr=/pin[2]/