Search code examples
androidgoogle-apps-scriptpostcharacter-encoding

Kodular Web Component "Post Text with Encoding" Block


Somewhere in my app I need to write some values to a Google Sheets document. When the text is in English alphabet everything is fine and the Google Sheet updates perfectly. But When I send Persian text, empty string is received on the Google side.

I’m using a Google App Script doPost(e) function to send data from my App to Google Sheets. First, I used the simple Post Text Block and I saw problem with Persian text. Then I replaced it with the Post Text With Encoding Block, but the problem still persists.

Here’s the App Script code:

function doPost(e) {

var ss = SpreadsheetApp.openByUrl(“https://docs.google.com/spreadsheets/d/**********tmk/edit#gid=150301410”);

var sheet = ss.getSheetByName(e.parameter.sheet);

var customerID = e.parameter.customerID;

var name = e.parameter.name;

var gender = e.parameter.gender;

var consultantID = e.parameter.consultantID;

var phone = e.parameter.phone;

var city = e.parameter.city;

var dateOfBirth = e.parameter.dateOfBirth;

var satisfaction = e.parameter.satisfaction;

var referredIDs = e.parameter.referredIDs;

sheet.appendRow([customerID, name, gender, consultantID, phone, city, dateOfBirth, satisfaction, referredIDs]);

return ContentService.createTextOutput(“Row with customerID " + customerID + " appended.”);

}

I’ve also attached a screenshot of my blocks.

enter image description here

Would be really grateful for any help :)

First, I used the simple Post Text Block and I saw problem with Persian text (Google sheet received empty string) . Then I replaced it with the "Post Text With Encoding Block", but the problem still persists.


Solution

  • SOLVED:

    The Persian texts needs to be encoded in an appropriate format for Web Post or Get.

    For example "گلابی" becomes "%DA%AF%D9%84%D8%A7%D8%A8%DB%8C" after encoding.

    There's a special function available in Kodular (UriEncode) which does just that.

    enter image description here