Blynk HTTP RESTful does not work

Hello,

I’m trying to write a pin value via PUT. I want to make this request from IFTTT and I use http://blynk-cloud.com/auth_token/update/D0 in which i filled in my token and a JSON body with [“1”]. I use Blynk version 2.26.2 on ios and use a Blynk Cloud server. As hardware I use a NodeMCU. I use blynk library version 0.6.1. When I am making the request via Postman it also does not work. When toggle the switch via the app the led which i connected to my pin D0 does turn on (my project is online). My code on arduino IDE is

#define BLYNK_PRINT Serial


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

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

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

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

  Blynk.begin(auth, ssid, pass);
}

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

I also tried to use the ip address from ping blynk-cloud.com but this also does not work.

First of all, you MUST use the IP address of the cloud server where your project lives (obtained by pinging Blynk-cloud.com) in your API call.
Secondly, this PUT API call on its own does nothing…
IPAddress/auth_token/update/D0
without any Body data to update the D0 pin with.

The best way of updating pins via IFTTT is to use GET rather than PUT, and to have the whole API call in the URL field and leave the body empty.
Using this method, you can assemble and test your API call simply by pasting it into the address bar of your browser rather than having to use Postman.
Note that if you don’t use the Blynk cloud servers IP address then it will work in your browser, as it resolves to the correct IP address, but the IFTTT server could be anywhere in the world and will therefore resolve to its local Blynk cloud server which probably won’t be the one that holds your project and will return an ‘Invalid token’ error - which you won’t see unless you delve deep into IFTTTs logs.

Pete.

I’m using the GET now but I’m still having trouble. I followed the instructions on this site
https://blynkapi.docs.apiary.io/#reference/0/write-pin-value-via-get/write-pin-value-via-get.
When i enter the API call in my browser I see nothing happening, only blank. I also use the pinged IP adress

It works in my browser now but not in IFTTT. I use exactly the same API call.

I think your screen will be blank when you do the update call, but the pin on your device should go to the state you’ve specified in the value (obviously it will need to be in the opposite state beforehand for you to see a change)

Does your URL look like this:

IPAddress/auth_token/update/D0?value=1

Pete.

Yes my url looks like that. I changed my pin and now it works in the browser but not on IFTTT.
I now have it connected to D8 which is D16 for Arduino IDE. So in my URL I use D16.

image

How are you triggering the IFTTT recipe? Are you sure this is working?
Does your applet activity say that it’s run x number of times and allow you to view the activity and show the details?

Pete.

It works. Thanks for your help

1 Like