2

I am writing a javascript in the Google spreadsheets and trying to fetch a URL. When i run curl on the same URL I am able to get it working. But when i try to use UrlFetchApp from javascript I get DNS error. Below is my code sample . Am I missing something ?

function upload() {
    Logger.log("hello, ");
    var headers = {
       'Content-Length' : 0
    };
    var options = {
        'method': 'post',
        'useIntranet': true,
        'validateHttpsCertificates': false,
         'contentType': 'text/xml'
     };
   var response = UrlFetchApp.fetch("http://localhost:8787/test/v2/feed", options);
   Logger.log("fetched data");
   Logger.log(response);
 }
Muppa Divya
  • 53
  • 2
  • 8

1 Answers1

7

This can't work. The UrlFetchApp is executing from a Google server, which isn't on the same network as your machine, so when it tries to find your server running on localhost it can't find it.

Seth Howard
  • 168
  • 1
  • 5
  • I have the same issue but I am accessing some other API which is on a dedicated server and can be accessed through postman and curl from any machine. Still I am getting same error. – Sanket Tarodekar Jul 11 '18 at 14:17