title: How to call web service on google app script
body: <p>I created a web service in SAP and I tried to call this SOAP web service from google app script.</p>
  
  <p>This WS is in BASIC authentication, in variable response I receive the same wsdl that I pass in input.
  I encountered a problem in back-end system call "Unsupported Content Type is received: " "
  Someone can help me?</p>
  
  <pre><code>var user = 'user';
  var pwd = 'pwd';
  var webservice = 'http://xx.xxx.xx.xx:xxxx/sap/bc/srt/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zdemo_google_ws/100/zdemo_google_ws/zdemo_google_ws?sap-client=100.wsdl';
  function readData() {  
  
  //Clean up anything currently on the spreadsheet  
  SpreadsheetApp.getActiveSheet().clear();  
  
  try {  
  
  //Various XML parsing.  
  var xml = "&lt;soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:soap:functions:mc-style\"&gt;"
  +"&lt;soapenv:Header/&gt;"
  +"   &lt;soapenv:Body&gt;"
  +"     &lt;urn:ZDemoGoogle&gt;"
  +"         &lt;ItWebs&gt;"
  +"            &lt;item&gt;"
  +"               &lt;Protocol&gt;&lt;/Protocol&gt;"
  +"               &lt;Tasktype&gt;&lt;/Tasktype&gt;"
  +"               &lt;EntryId&gt;&lt;/EntryId&gt;"
  +"               &lt;Account&gt;&lt;/Account&gt;"
  +"               &lt;Mandt&gt;&lt;/Mandt&gt;"
  +"               &lt;Host&gt;&lt;/Host&gt;"
  +"               &lt;Port&gt;&lt;/Port&gt;"
  +"               &lt;Destination&gt;&lt;/Destination&gt;"
  +"               &lt;Path&gt;&lt;/Path&gt;"
  +"               &lt;Counter&gt;&lt;/Counter&gt;"
  +"               &lt;Calltime&gt;&lt;/Calltime&gt;"
  +"               &lt;ExecutionTi&gt;&lt;/ExecutionTi&gt;"
  +"               &lt;DataSend&gt;&lt;/DataSend&gt;"
  +"               &lt;DataSendTi&gt;&lt;/DataSendTi&gt;"
  +"               &lt;DataReceive&gt;&lt;/DataReceive&gt;"
  +"               &lt;DataReceiveTi&gt;&lt;/DataReceiveTi&gt;"
  +"            &lt;/item&gt;"
  +"         &lt;/ItWebs&gt;"
  +"      &lt;/urn:ZDemoGoogle&gt;"
  +"   &lt;/soapenv:Body&gt;"
  +"&lt;/soapenv:Envelope&gt;"
  
  var options = {  
    headers: {  
      "Authorization": "Basic " + Utilities.base64Encode(user + ':' + pwd),
      "method" : "post",
      "contentType" : "text/xml",
      "payload" : xml,
      "muteHttpExceptions":true
    },  
  };  
  
  //UrlFetchApp is a powerful built-in library from Google  
  
  var serviceaddress =  webservice ;
  var response = UrlFetchApp.fetch(serviceaddress, options);
  </code></pre>