Dean
Dean

Reputation: 1

Gmail App Scripts AddOn: XMLHttpRequest Error

I am developing a Gmail App Scripts Ad-On. I am able to create cards, and child cards, and add controls to the cards, and it works well. However, I need to add functionality to make an oData call to a web service in another application. As soon as I add the following line in my code.gs file I get the error shown below when I run my add-on in Gmail.

var req = new XMLHttpRequest();

ReferenceError: "XMLHttpRequest" is not defined. [line: 187, function: gotoChildCard, file: Code]

It never even gets beyond that line, so it is not any problem with oData structure or anything, it does not like that line. I have tried to find some posts, but I cannot find anything (I did find some people getting this error when they develop a Chrome Extension, but that is different - I am creating a Gmail App Scripts Add-On). I was thinking that maybe I need to add something to my manifest file, but if so, I do not know what it is.

below is my appscript.json file:

`{
  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.addons.execute",
    "https://www.googleapis.com/auth/gmail.readonly"
  ],
  "gmail": {
    "name": "Dean's Gmail Add-On:  Multiple Cards for Set ",
    "logoUrl": "https://www.gstatic.com/images/icons/material/system/2x/bookmark_black_24dp.png",
    "contextualTriggers": [{
      "unconditional": {
      },
      "onTriggerFunction": "createNavigationCard"
    }],
    "openLinkUrlPrefixes": [
      "https://mail.google.com/"
    ],
    "primaryColor": "#4285F4",
    "secondaryColor": "#4285F4",
    "version": "TRUSTED_TESTER_V2"
  }
}

Upvotes: 0

Views: 427

Answers (1)

machine-wisdom
machine-wisdom

Reputation: 133

You can only make HTTP requests using the UrlFetchApp in Apps Scripts

Upvotes: 2

Related Questions