Skip to main content
Solved

Hey guys I need your help

  • June 28, 2020
  • 5 replies
  • 50 views

Does the custom block API allow us to call POST/GET requests to external services such as one’s own AWS EC2? It seems that I can only call Wikipedia and other services fail

Best answer by Ashwin_P

As even the calls to openweather fail. I’m trying to connect to my AWS EC2 instance

const weatherURL =
http://api.openweathermap.org/data/2.5/forecast?zip=11102&units=imperial&APPID=key
fetch(weatherURL)
.then(res => res.json())
.then(data => console.log(“Data List Loaded”, data.list))


The URL has to start with https

5 replies

Forum|alt.badge.img+13
  • Known Participant
  • 25 replies
  • June 28, 2020

It’s possible, it might be other kind of issue


  • Author
  • New Participant
  • 2 replies
  • June 28, 2020

It’s possible, it might be other kind of issue


Have you managed to make a POST request to anything other than Wikipedia before?


  • Author
  • New Participant
  • 2 replies
  • June 28, 2020

It’s possible, it might be other kind of issue


As even the calls to openweather fail. I’m trying to connect to my AWS EC2 instance

const weatherURL =
http://api.openweathermap.org/data/2.5/forecast?zip=11102&units=imperial&APPID=key
fetch(weatherURL)
.then(res => res.json())
.then(data => console.log(“Data List Loaded”, data.list))


  • Known Participant
  • 10 replies
  • June 29, 2020

I’ve indeed made other calls (to my own BE service) as part of this custom blocks beta. For better and for worse, it’s likely a coding error on your side.

Here’s part of the code I have in my current block:

const payload = {
    config: config._kvStore,
    message,
  };

  request.post(
    {
      headers: { 'content-type': 'application/json' },
      url: `${ENV.DEV.BASE_API}do_something`,
      body: JSON.stringify(payload)
    },
    function (error, response, body) {
      if (error) {
        console.error(error);
      } else {
        console.log(body);
      }
    }
  );

Forum|alt.badge.img+3
  • Inspiring
  • 25 replies
  • Answer
  • June 29, 2020

As even the calls to openweather fail. I’m trying to connect to my AWS EC2 instance

const weatherURL =
http://api.openweathermap.org/data/2.5/forecast?zip=11102&units=imperial&APPID=key
fetch(weatherURL)
.then(res => res.json())
.then(data => console.log(“Data List Loaded”, data.list))


The URL has to start with https