1

I have a project in GCP with some internal APIs (in VMs), Databases, and so on. Now, I'm trying to create a GAS to obtain data from one of those internal APIs (Druid, in my case) to print some data in a Google Spreadsheet.

My point here is that I link the GAS to my GCP project, expecting to be able to connect to my internal IP (10.1.0.x) which is in a VPC, shared with the default one. So, if I start a new VM attached to the default network, I could be able to ping and connect to it. Seems reasonable.

But, when I execute the GAS function, the following pice of code fails: UrlFetchApp.fetch('http://10.1.0.3:8082/druid/v2/?pretty', options);.

Should I configure something else in the GCP project to be able to connect to internal APIs? Should I change the way and use another GCP service to do so?

Any help would be more than appreciated! Thanks

  • Possible duplicate of [UrlFetchApp unable to access localhost resource](https://stackoverflow.com/questions/30085768/urlfetchapp-unable-to-access-localhost-resource) – TheMaster Aug 14 '19 at 11:32

2 Answers2

0

That is not supported in Apps Script. You could request a feature request in the bug tracker. See https://developers.google.com/apps-script/support#missing_features

Jeremy
  • 2,321
  • 3
  • 21
  • 24
0

Internal APIs run client-side and need to be incorporated within JavaScript code.

Within Apps Script you can run JavaScript code, if you deploy your project as a Web App.

You can then either embed the JS code within the HTML file attached to the project, or directly insert it within the <script></script> tags within HtmlService.createHtmlOutput().

ziganotschka
  • 25,866
  • 2
  • 16
  • 33