Error while trying to retrieve data from google sheet?

hello everyone.
i faced a problem while am trying to retrieve data from google sheet the data was sent before using the same app (i use uriencode) to let google sheet read arabic data as shown in images below.

the script i use to retrieve the data is:

function doGet(e) {

  return ManageSheet(e);

}

function doPost(e) {

  return ManageSheet(e);

}



function ManageSheet(e) {



  //READ ALL RECORDS

  if ( e.parameter.func == "ReadAll") {

    var ss = SpreadsheetApp.getActive();

    var sh = ss.getSheets()[0]; 

    var rg = sh.getDataRange().getValues(); 

    var outString = '';

      for(var row=0 ; row<rg.length ; ++row){

        outString += rg[row].join(',') + '\n';  

      } 

    return ContentService.createTextOutput(outString).setMimeType(ContentService.MimeType.TEXT);

  }
 //DELETE SINGLE RECORD

   else if (e.parameter.func == "Delete") {

    var record = e.parameter.model;

    var ss = SpreadsheetApp.getActive();

    var sh = ss.getSheets()[0];

    sh.deleteRow(parseInt(record) + 1);  

    return ContentService.createTextOutput("Success"); 

 }
}


blocks

You do not show the error ?

Also, there is no need to set the spreadsheet ID or Sheet, because these are set in the script (which I presume is a bound script)

image

If you take those out then

image

needs to be:

?func=ReadAll   <<(replace the & with ? )

thanks alot i did what you told me to do
now i got error massage "cannot parse text argument to "list from csv table" as a csv-formatted table "

Please show the output of response content

The response content in your Web1.gotText event

1 Like

sorry
could u tell me how to do that ?

Can you translate what it says in arabic in that error message, please?

Is your spreadsheet currently empty apart from the header row ?

.file line 78

no its not empty its just as i reply

Is that in your data ?

Your script is not that long ?

If I view your spreadsheet, Garage, it only contains a header row, or is that just an example ?

even if there is data the same error keep showing
i sent you all blocks since sent to google to the moment i retrieve with the script
i sent data as shown on image using uriencode

i sent you the part reading script here is all script:

function doGet(e) {

var ss = SpreadsheetApp.openByUrl("Garage - Google Sheets");

var sheet = ss.getSheetByName("Sheet1");

addUser(e,sheet);

}

function doPost(e) {

var ss = SpreadsheetApp.openByUrl("Garage - Google Sheets");

var sheet = ss.getSheetByName("Sheet1");

addUser(e,sheet);

}

function addUser(e,sheet) {

var timestamp = e.parameter.timestamp ;

var model = e.parameter.model ;

var platenumber = e.parameter.platenumber;

var maintinance1 = e.parameter.maintinance1 ;

var maintinance2 = e.parameter.maintinance2 ;

var maintinance3 = e.parameter.maintinance3;

var maintinance4 = e.parameter.maintinance4;

var maintinance5 = e.parameter.maintinance5;

var newpart1 = e.parameter.newpart1;

var price1 = e.parameter.price1;

var newpart2 = e.parameter.newpart2;

var price2 = e.parameter.price2;

var newpart3 = e.parameter.newpart3;

var price3 = e.parameter.price3;

var newpart4 = e.parameter.newpart4;

var price4 = e.parameter.price4;

var newpart5 = e.parameter.newpart5;

var price5 = e.parameter.price5;

var newpart6 = e.parameter.newpart6;

var price6 = e.parameter.price6;

var newpart7 = e.parameter.newpart7;

var price7 = e.parameter.price7;

var newpart8 = e.parameter.newpart8;

var price8 = e.parameter.price8;

var newpart9 = e.parameter.newpart9;

var price9 = e.parameter.price9;

var newpart10 = e.parameter.newpart10;

var price10 = e.parameter.price10;

sheet.appendRow ([timestamp,model,platenumber,maintinance1,maintinance2,maintinance3,maintinance4,maintinance5,newpart1,price1,newpart2,price2,newpart3,price3,newpart4,price4,newpart5,price5,newpart6,price6,newpart7,price7,newpart8,price8,newpart9,price9,newpart10,price10]);

}

function doGet(e) {

return ManageSheet(e);

}

function doPost(e) {

return ManageSheet(e);

}

function ManageSheet(e) {

//READ ALL RECORDS

if ( e.parameter.func == "ReadAll") {

var ss = SpreadsheetApp.getActive();

var sh = ss.getSheets()[0]; 

var rg = sh.getDataRange().getValues(); 

var outString = '';

  for(var row=0 ; row<rg.length ; ++row){

    outString += rg[row].join(',') + '\n';  

  } 

return ContentService.createTextOutput(outString).setMimeType(ContentService.MimeType.TEXT);

}

//DELETE SINGLE RECORD

else if (e.parameter.func == "Delete") {

var record = e.parameter.model;

var ss = SpreadsheetApp.getActive();

var sh = ss.getSheets()[0];

sh.deleteRow(parseInt(record) + 1);  

return ContentService.createTextOutput("Success");  

}

}

I have just created a spreadsheet and script to test, works OK for me

SHEET
image

SCRIPT

function doGet(e) {

var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[0]; 
  
//READ ALL RECORDS
  if ( e.parameter.func == "ReadAll") {
    var rg = sh.getDataRange().getValues(); 
    var outString = '';
      for(var row=0 ; row<rg.length ; ++row){
        outString += rg[row].join(',') + '\n';  
      } 
    return ContentService.createTextOutput(outString).setMimeType(ContentService.MimeType.TEXT);

  }
}

URL (you can test this in your browser)

https://script.google.com/macros/s/AKfycbwvFYEjxRF5Xj4JQSZnDyk29psEcb7B55WBL8lizFGieHlVLiM/exec?func=ReadAll

OUTPUT

timestamp,model,platenumber,maintinance1,maintinance2,maintinance3
Sat Dec 30 1899 10:00:00 GMT+0000 (Greenwich Mean Time),Ford,123456,1,2,3
Sat Dec 30 1899 11:00:00 GMT+0000 (Greenwich Mean Time),Land Rover,234567,2,3,4
Sat Dec 30 1899 12:00:00 GMT+0000 (Greenwich Mean Time),BMW,345678,3,4,5

You could try changing:

var rg = sh.getDataRange().getValues();

to

var rg = sh.getDataRange().getDisplayValues();

see if that helps...

i see that surely will work bcoz u just write the data manually but what i made is sending data using the app to the sheet then retrieve data from the same sheet using the same script page

may should i make a new script for retrieving or that just didn't work

This should not make any difference.....

may that coz i have sent the data using uriencode