I'm trying to invoke a service that sends a sms from a google apps script. The service wants the data in iso 8859-1. The code below send a message with the åäö as bad chars.
function sendSMS() {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var cell = doc.getRange('b8');
var payload =
{
"username" : "XXXX",
"password" : "YYYY",
"nr" : "0123123123",
"type" : "text",
"data" : "Hello world...åäö"
};
var options =
{
"method" : "post",
"payload" : payload
};
var response = UrlFetchApp.fetch("http://www.mosms.com/se/sms-send.php", options);
Browser.msgBox(response.getContentText());
}
function testFetch (){
var response = UrlFetchApp.fetch("http://www.google.com/");
Browser.msgBox(response.getContentText());
}
As mentioned in the other question that Serge linked to in the comments, you can change the encoding of a string by first converting it to a Blob and then using the
getDataAsString()
method: