Cooper
Cooper

Reputation: 64062

Can't Get Firebase Google App Script Quickstart Tutorial to Work

I can't seem to get the Firebase QuickStart to work for me. I'm pretty sure that I followed all of the instructions correctly. But I'm not getting access to write to the database. And according to the instructions the database is currently open to the public with the suggest rules change displayed below. Has anybody ever gone through this tutorial before? I'd like a hint as to what to do next.

Here's the code.

  function writeDataToFirebase() {
  var ss = SpreadsheetApp.openById("1rV2_S2q5rcakOuHs2E1iLeKR2floRIozSytAt2iRXo8");
  //var ss = SpreadsheetApp.getActive();//I tried running it with data in this spreadsheet copied from the recommended source
  var sheet = ss.getSheets()[0];
  //var sheet = ss.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  var dataToImport = {};
  for(var i = 1; i < data.length; i++) {
    var firstName = data[i][0];
    var lastName = data[i][1];
    dataToImport[firstName + '-' + lastName] = {
      firstName:firstName,
      lastName:lastName,
      emailAddress:data[i][2],
      country:data[i][4],
      department:data[i][5],
      weight:data[i][6],
      birthDate:data[i][7]
    };
  }
  var firebaseUrl = "https://script-examples.firebaseio.com/";
  var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
  base.setData("", dataToImport);
}

The Data:

enter image description here

This is my library dialog:

enter image description here

This is the error I keep on getting:

enter image description here

This name of my script in the FireBase Site:

enter image description here

This is the access rules change:

enter image description here

Upvotes: 0

Views: 588

Answers (1)

Cooper
Cooper

Reputation: 64062

So I guess I missed an important point. The url of firebase database has your projectId in it. So the url would be something like https://' + projectId + '.firebaseio.com'. Sorry, to bother everyone with such a simple question.

Upvotes: 1

Related Questions