Muppa Divya
Muppa Divya

Reputation: 53

UrlFetchApp DNS error

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);
 }

Upvotes: 2

Views: 7849

Answers (1)

Seth Howard
Seth Howard

Reputation: 168

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.

Upvotes: 7

Related Questions