Need help with API

Hi Pete,
I’m struggling since one week to get it work from web without any success, I think there is an issue with the server location because when I was in France I could use UPDATE and it was working fine but GET never work from Web page… I alse posted in another thread the same issue but without any replay…
Now I’m in Asia and both of them are not working from Web, but from my Amazon Alexa app (node js) UPDATE is working but GET still not work and I receive always “invalid Token” when I try to send the link as described in the documentation HTTP REST full API. Even after replacing the blynk server with the pinged one …

If anyone has success with it , please advise…

Thanks and regards
Bek

The first time thing you need to do is to work-out which cloud server your project lives on, and use the IP address of that server in your API call.

Pete.

Already done I replace the serve blynk-cloud.com by the ping one 188.166.206.43, same result Blynk is working fine from my mobile, Alexa works fine as long as I use only UPDATE and not GET, from WEB non of them works … very strange because the UPDATE link works from ALEXA but not from the WEB…

What else should I do to work-out which cloud server my project lives on?

Regards
Bek

One thing strange I noticed, is that with node js in Alexa I use the method GET with the link of UPDATE. !!! . and this works from Alexa… when I send the same link from Web it doesn’t…

const myAuthPath = '/D4AU1HexWcErQ9vtpkP_EgocpnoArZKC/update/';
const valueString = '?value='
var virtualPin;
var virtualPinValue;


function sendToBlynk (_virtualPin, _virtualPinValue)
  {
   const blynkPath = myAuthPath.concat(_virtualPin).concat(valueString).concat(_virtualPinValue);
        var options = 
            {
            host: 'blynk-cloud.com',
            path: blynkPath,
            port: 80,
            method: 'GET'
            }
        const req = http.request(options, (res) => { });
        // send the request
        req.write('');
        req.end();
}

You project lives on the Frankfurt server. Th IP address is 139.59.206.133

If you mane an API call to:

139.59.206.133/D4AU1HexWcErQ9vtpkP_EgocpnoArZKC/project

it returns the JSON for your project. The same call to 188.166.206.43 returns “Invalid token”, meaning that no project with your auth token exists on that server.

Pete.

@bek please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Hi Pete,

That works fine, means that I should always use this IP to be safe with all my APIs…?
but how could I know that my project lives on the Frankfurt server and the IP is 139.59.206.133 ?

Thanks
Bek

Fix your unformatted code, using the correct characters and I’ll respond, otherwise your post will be deleted.

Pete.

Done, edited with triple ticks …

No it isn’t.
I provided you with triple backticks, why not copy/paste them instead of using different characters and hoping that they will do the same job (which they don’t).

Pete.

Done, With copy and paste… should I do it for every post or only when I post codes?

No you haven’t!

You’ve added what appear to triple decimal points to your last post, which is crazy.

Post #4 needs triple backticks around the code, so that the code displays correctly.

Pete.

Thanks … Now I understand … please check…

At last!!

Yes, 100%

If you look at your device (Arduino) when it connects the serial monitor will show “redirecting to 139.59.206.133“

Otherwise you can make the auth_token/project call to the three cloud server IPs to see which one returns the JSON.

I don’t really understand your question. The API describes POST and GET methods and their different syntax. My experience is always to use GET to both read and write virtual pins.

Pete.

Great, thanks a lot for the detailed explanation …now its clear for me and it works also with Labview …

Best regards
Bek