Blynk Webhook GET Request example not working?

hi,
I am using the blynk example here, but instead of the actual GET data going into V0 I am getting the literal URL https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt as the value of V0… and not the logo itself… any idea why?

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  WARNING!
    It's very tricky to get it working. Please read this article:
    http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware

  This example shows how to fetch data using WebHook GET method

  App project setup:
    WebHook widget on V0, method: GET, url: /pin/
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
// Allow for receiving messages up to 512 bytes long
//#define BLYNK_MAX_READBYTES 512

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "myauth";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "myssid";
char pass[] = "mypass";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(8, 9); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

BLYNK_WRITE(V0)
{
  Serial.println("WebHook data:");
  Serial.println(param.asStr());
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8442);

  Blynk.virtualWrite(V0, "https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");

  // You can perform HTTPS requests even if your hardware alone can't handle SSL
  // Blynk  can also fetch much bigger messages,
  // if hardware has enough RAM (set BLYNK_MAX_READBYTES to 4096)
  //Blynk.virtualWrite(V0, "https://api.sunrise-sunset.org/json?lat=50.4495484&lng=30.5253873&date=2016-10-01");
}

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

Because AFAIK that is how it works :stuck_out_tongue_winking_eye: You effectively loaded a vPin with a string of data.

OK, I see… you are trying the Webhook GET sketch, NOT the GET Data sketch… I fixed your title.

Did you follow the direction listed in the readme of this sketch?

App project setup:
    WebHook widget on V0, method: GET, url: /pin/

Hehe… well you are actually getting further then I am… After connection, nothing else happens at all on my serial monitor.

I honestly have not needed to use Webhook before… and clearly I might not be the right one to answer your question :blush:

@Dmitriy OK, somehow the example/widget is still messed up??

As per this topic

Putting in /pin/ into the Widget still gives error on either Cloud or Local Server…

…and I have not yet been able to get it to work as advertised.


But if you put the URL directly in the Webhook Widget, it will work…

image

Clearly only a one shot setup if requiring manual pasting URL each time :frowning:

What are we missing here?

1 Like

This error is just a reminder of possible error case, I guess we’ll change its color for that case. That “/pin/” would be saved in the WebHook and it will use it, about how it works (or not)) maybe @Dmitriy could respond.

Yes… based on some testing…

Using /pin/ in the Webhook Widget and adding in a button that calls this…

BLYNK_WRITE(V1) {  // Button
  if (param.asInt() == 1) {
    Blynk.virtualWrite(V0, "https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");
  }
}

…will get no response in the Serial monitor as it should from this…

BLYNK_WRITE(V0)
{
  Serial.println("WebHook data:");
  Serial.println(param.asStr());
}

but if I also add in a Terminal Widget, on same V0, it will show this… (only after the 2nd button press, then it catches up and repeats the URL each press)…

image

So, I agree, it is using the /pin/ but not really the way it should (as indicated in the example).

Yay!!! my first real use of Webhooks… but just not seeing the glamor :face_with_raised_eyebrow: :stuck_out_tongue_winking_eye:

Webhook has validation that expects real URL in the text field. Setting the url via vritualWrite is not supported due to security issues.

Looks legit - https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt

and both Example and the Widget itself clearly state using /pin/ as an option

image

Then perhaps the Web Hook GET example needs to be modified?

As well at the Widgets settings.

I knew I should have ignored this topic :stuck_out_tongue: But I did want to learn more about Webhooks…

Hm… I don’t remember adding this example :). Need to think about it.

Better you than me :slight_smile: And here I thought it might be a simple bug, not a security thing… outta my league :stuck_out_tongue:

Did a fix - https://github.com/blynkkk/blynk-server/issues/898

1 Like

Wow, quick… :slight_smile:

What is required for the OP to get back to working with this? wait for App and/or Local Server upgrade or simple wait for Cloud Server to process fix?

Yeap. Wait for next deployment that is not planned to be soon :slight_smile:.

1 Like

Thank you @Dmitriy :+1: I will mark this solved and run, not walk, away from webhooks for a while :stuck_out_tongue:

@nirkon as the library is at the moment the following sketch will work for ESP standalone. As per the comments use https:///pin/ (3 forward slashes after https:) in the Webhook widget.

/*************************************************************
  Webhook_GETrev1.ino for https://community.blynk.cc/t/blynk-webhook-get-request-example-not-working/21754

  This example shows how to fetch data using WebHook GET method

  App project setup:
    WebHook widget on V0, method: GET, url: https:///pin/ (3 forward slashes after https:)
    Button in PUSH mode on V1 - push button to display Blynk logo in Serial Monitor
 *************************************************************/

#define BLYNK_PRINT Serial
// Allow for receiving messages up to 512 bytes long
//#define BLYNK_MAX_READBYTES 512

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxx";
char ssid[] = "xxx";
char pass[] = "xxx";

BLYNK_WRITE(V0)
{
  Serial.println("WebHook data:");
  Serial.println(param.asStr());
}

BLYNK_WRITE(V1)
{
  if(param.asInt()){
    //Blynk.virtualWrite(V0, 1);
    Blynk.virtualWrite(V0, "raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");  
  }
}

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

  Blynk.virtualWrite(V0, "raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");

  // You can perform HTTPS requests even if your hardware alone can't handle SSL
  // Blynk  can also fetch much bigger messages,
  // if hardware has enough RAM (set BLYNK_MAX_READBYTES to 4096)
  //Blynk.virtualWrite(V0, "api.sunrise-sunset.org/json?lat=50.4495484&lng=30.5253873&date=2016-10-01");
}

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

Will your fix break the working sketch I have just posted?

@Costas good hack, working great!.. I did try your prior h/pin/ one, but to no avail.

But it will be nice to have it working with proper URLs in the (distant?) future.

No.

1 Like