I am trying to upload data from an app to a Google Spreadsheet using the Google App Script but the webapp is not working. I have republished the app after the following state but it still does not work and I keep getting the error.
The script completed but did not return anything.
I have also made the permission changes for both the spreadsheet and the app.
WebApp Code
var ss = SpreadsheetApp.openByUrl("SpreadSheet Link");
var sheet = ss.getSheetByName('Items')
function doPost(e){
var action = e.parameter.action;
if(action == 'addItem'){
return addItem(e);
}
}
function addItem(e){
var date = new Date();
var rssi = e.parameter.RSSI;
var id = e.parameter.UUID;
var time = e.parameter.TimestampCode;
var scanSetting = e.parameter.ScanSetting;
var advSetting = e.parameter.AdvertisementSetting;
sheet.appendRow([date,rssi, id,time,scanSetting, advSetting]);
return ContentService.createTextOutput("Success").setMimeType(ContentService.MimeType.TEXT);
}
Android App Function
private void addItemToSheet(String rssi, String uuid, long timeStamp) {
final ProgressDialog loading = ProgressDialog.show(this,"Adding Item","Please wait");
String rssiData = rssi;
String uuidData;
if(uuid == null){
uuidData = "null";
}
else {
uuidData = uuid;
}
String timeStampData = String.valueOf ( timeStamp );
String scanSettingChosen = scanSetting;
String advSettingChosen = advSetting;
StringRequest stringRequest = new StringRequest( Request.Method.POST, "WebApp Link",
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
loading.dismiss();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}
) {
@Override
protected Map<String, String> getParams() {
Map<String, String> parmas = new HashMap<> ();
//here we pass params
parmas.put("RSSI",rssiData);
parmas.put("UUID",uuidData);
parmas.put("TimestampCode",timeStampData);
parmas.put("ScanSetting",scanSettingChosen);
parmas.put("AdvertisementSetting",advSettingChosen);
return parmas;
}
};
int socketTimeOut = 120000;
RetryPolicy retryPolicy = new DefaultRetryPolicy (socketTimeOut, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
stringRequest.setRetryPolicy(retryPolicy);
RequestQueue queue = Volley.newRequestQueue(this);
queue.add(stringRequest);
}