Problem with accent character when making a GET request for google app script

0

Hello, is everything good?

I'm doing an HTTP REquest GET for Google App Script

    strUrl = "https://script.google.com/macros/s/ID/exec"
strUrl = strUrl & "?admissao=" & admissao
strUrl = strUrl & "&cidade=" & cidade
strUrl = strUrl & "&nome=" & funcionario
strUrl = strUrl & "&funcao=" & funcao
strUrl = strUrl & "&salariobase=" & salario


Dim objHTTP As Object
Dim URL As String
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = strUrl
objHTTP.Open "GET", URL
objHTTP.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
objHTTP.SetRequestHeader "content-encoding", "gzip"
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"
objHTTP.SetRequestHeader "Accept-Language", "en-US,en;q=0.8"
objHTTP.Send ("")
strResult = objHTTP.ResponseText

And the Script has the function of picking the parameters and saving in a Google Sheets table.

My Google App Script doGet () function is like this

    function doGet(e) { 
  var ss = spreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/ID/edit#gid=0");
  var sheet = ss.getSheetByName("CadastroFuncionario"); 

  addUser(e,sheet);

  var result = "";

  try {

  var admissao = e.parameter.admissao; 
  var demissao = ""; 
  var cidade = e.parameter.cidade; 
  var  nome = e.parameter.nome;
  var funcao = e.parameter.funcao;
  var salariobase = e.parameter.salariobase;
  var situacao = "Ligado";

    result = 'OK';
  } catch (f) {
    result = "Error: " + f.toString();
  }

  result = JSON.stringify({
    'result': result
  });    

  return ContentService
  .createTextOutput(e.parameter.callback + "(" + nome + " "+result + ")")
  .setMimeType(ContentService.MimeType.JAVASCRIPT); 

}

However, if the parameter has an accent like Ç or ã, this character appears on the google sheet.

  • I have tried to encode the URL to hex.
  • I've already used .getDataAsString ('UTF-8'); in the variable to convert it to UTF-8 and did not work

What else can I do?

    
asked by anonymous 29.11.2018 / 15:00

0 answers