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