Error while trying to retrieve data from google sheet?

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

i try many thing but the result was the same.
plz if anybody have an ideas

Show your script and show your spreadsheet with data

Edited.

have you add the apostrophes (' ')` proerly? even single mistake will leads to total collapse of the work..

you mean apostrophes :wink:

1 Like

oh sorry, yes i am.. may be he commit mistake over there.. because me too had the same experience

You posted on another topic that you found the solution:

Were you using a different spreadsheet, or not using a bound script (created from within the spreadsheet) - using a standalone script ?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.