Webhook - GET and VirtualWrite?

Uhh, Should we really use VirtualWrite with GET on Webhook like in the docs? Shouldn’t VirtualWrite be used with PUT/POST?

It depends. HTTP REST standard says that you shouldn’t do updates with GET request, however if you look on thingspeak API you’ll see that they propose to do updates (POST/PUT) with GET request :slight_smile:. That’s fine as it is simplifies things a lot and you can do update from browser command line.

So in other words GET is not necessarily get. It could be update too.

We just added support for this. Please check updated docs.

Can somebody please support me on Post request with Arduino Yun? Trying to use Google Geolocation API but cannot get the following response:

{
“location”: {
“lat”: 47.1516862,
“lng”: 14.7316925
},
“accuracy”: 823.0
}

Please find below my sketch:


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

 #include <SPI.h>
 #include <Ethernet.h>
 #include <Bridge.h>
 #include <BlynkSimpleYun.h>

char auth[] = "28f8f1ca6f1a54e049afe9d894bcbd28f1";
// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);


BLYNK_WRITE(V16){   // Value Display Widget for  Webhook
  String webhookdata = param.asStr();
  Serial.println(webhookdata);
  yield();
  if((webhookdata.length() >= 1) && (webhookdata.length() < 1024)){ 
    Serial.println("WebHook data:");
    Serial.println(webhookdata);
    Serial.print("Data size: ");
    Serial.println(webhookdata.length()); 
    terminal.println(webhookdata);
    terminal.print("Data size: ");
    terminal.println(webhookdata.length());
    terminal.flush(); 
  }
  webhookdata = "";
  yield();
}

BLYNK_WRITE(V17){ // button to trigger API
  int V17btn = param.asInt(); 
  if(V17btn ==  1){
    terminal.println("API........");
    terminal.flush(); 
    Blynk.virtualWrite(V16,"https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSy2AhUm9NoXKyXwgSz-hn009rXmf5V172kcrk");
    //Blynk.virtualWrite(V16, "https://raw.githubusercontent.com/blynkkk/blynk-library/master/extras/logo.txt");
  }
}

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

  Blynk.begin(auth);
  Blynk.begin(auth, "blynk-cloud.com", 8442);
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.flush();
  
}

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