I'm trying to get a response from a Java servlet and return it to a Gmail Add-On by using the following function:
function getResponse(){
var url = "dgdespacho.nubbius.com/AddOn?command=searchRecords&clientName=&recordName=993&recordNo=&token=2671db95-3ece-40d9-842e-b573fc6a6ee6";
var response = UrlFetchApp.fetch( url );
Logger.log( response.getContentText() )
}
It should return a JSON-able string. When I make the request of the same url directly on a browser, it shows as it should:
{"data":[{"recordName":"prueba 993","id":5781921682423808}],"records":1,"status":0}
But inside the Add-On I always get an (incomplete) HTML text instead of a JSON:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=300, initial-scale=1" name="viewport">
<meta name="google-site-verification" content="LrdTUW9psUAMbh4Ia074-BPEVmcpBxF6Gwf0MSgQXZs">
<title>Sign in - Google Accounts</title>
<style>
@font-face {
[...]
I'm using the same structure that's shown in the documentation:
var response = UrlFetchApp.fetch("http://www.google.com/");
Logger.log(response.getContentText());
I've searched for similar questions (and primarily checked this one, as the other ones I've found don't really focus on the same topic) but they haven't solved this either.
What am I missing? How can I retrive with Apps Script what I retrieve when copying and pasting the same url on a web browser, if it's not using UrlFetchApp.fetch( url )
?