Aaron Harris
Aaron Harris

Reputation: 415

Automated Apps Script for BigQuery Not Connecting To Right Project?

I'm getting the below problem with apps script which is attempting to run a query and create a table, TEST4, in BigQuery. The error is:

"Project 603804914871 is not found and cannot be used for API calls. (line 19, file "Code")"

Query is:

saveQueryToTable() {
      var projectId = 'fiery-cabinet-****';
      var datasetId = '11234***1';
      var tableId = 'TEST4';
      var job = {
        configuration: {
          query: {
            query: 'SELECT *' +
                   'FROM Test2;',
            destinationTable: {
              projectId: projectId,
              datasetId: datasetId,
              tableId: tableId
            }
          }
        }
      };

  var queryResults = BigQuery.Jobs.insert(job, projectId);
  Logger.log(queryResults.status);
}

Could anyone let me know where I'm going wrong?

I can find that project in my console, I can enable the bigquery API for that project and then I don't get any errors... however it doesn't run the query or save to a new table "TEST4"?

Upvotes: 0

Views: 617

Answers (1)

Aaron Harris
Aaron Harris

Reputation: 415

Response from @KENDi was correct. I had to enable the API in the Google Developer Console.

Upvotes: 1

Related Questions