If I enter the url directly in the browser I can succesfully write the pin.
If I try to do it via javascript as written in the api documentation it doesn’t work.
The strange thing is also that I get “0” as returned stats value.
Here below the simple example that I’m trying to use (of course auth_token as to be replaced with your token).
If you’re running an API call on a remote server then its always a good idea to put the actual IP address of the Blynk cloud server that holds your project, rather than allowing the remote server to try to resolve the IP address itself, as it could hit the wrong server.
Ping blynk-cloud.com from your home PC and use that IP address in your API call.
Hello PeteKnight,
thank you for your reply.
I have tried with http://139.59.206.133/auth_token/update/V0?value=0 but I have the same result.
If I use it from the url bar in the browser it works, if I use it inside JavaScript it doesn’t work and it returns 0.
Any other idea?
I know nothing about HTML or the function that you are using to make this API call, but the API call needs to be a JSON request. Is that what this does?
Hello @juninhuhlima,
thank you for your code.
Actually the http get request in our codes are the same, log the body instead the status will change only the effect of the returned value displayed, but not the http request.
Due to you are telling me that for you is working, I’ve thinked what could be wrong in my setup and finally I found the issue: I was trying the code using the HTML editor of https://www.w3schools.com/html/tryit and with this the code doesn’t work.
I have just edited manually a text file with the same code, changed the extension in html and opened it with the browser and it works!
So the code was correctly from the begging.
I have also verified that the correct return value is in status and not in body.