API Call

53 views
Skip to first unread message

arul selvan

unread,
Apr 1, 2024, 5:39:53 AMApr 1
to Google Apps Script Community
I want to convert the below Java Script code to AppScript. I want this to work from my google sheet by AppScript function (container bound) by UrlFetchApp.fetch(url)

The code sends an SMS to any number from from a google sheet if user clicks a button.

I will be very thankful to you for your help



const data = "{\n \"template_id\": \"660a57d7dd14da0a3\",\n \"short_url\": \"1 (On) or 0 (Off)\",\n \"recipients\": [\n {\n \"mobiles\": \"919790034416\",\n \"var\": \"test\",\n \"var1\": \"test1\"\n }\n ]\n}"; const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } }); xhr.open("POST", "https://control.msg91.com/api/v5/flow/"); xhr.setRequestHeader("authkey", "418258ANW1660a5a3cP1"); xhr.setRequestHeader("content-type", "application/JSON"); xhr.send(data);


Andrew Apell

unread,
Apr 2, 2024, 4:25:45 PMApr 2
to Google Apps Script Community
I used GPT-4:

var data = {
  "template_id": "660a57d7dd14da0a3",

  "short_url": "1 (On) or 0 (Off)",
  "recipients": [
    {
      "mobiles": "919790034416",
      "var": "test",
      "var1": "test1"
    }
  ]
};

var options = {
  "method": "post",
  "headers": {
    "authkey": "418258ANW1660a5a3cP1",
    "content-type": "application/JSON"
  },
  "payload": JSON.stringify(data)
};


UrlFetchApp.fetch('https://control.msg91.com/api/v5/flow/', options);
Reply all
Reply to author
Forward
0 new messages