14

I have a google appscript that calls the Big Query API. It's working fine, but I want to duplicate the sheet and use for a different set of reports. I've duplicated the file once successfully a couple of months ago.

Now when duplicating the report and authenticating with the Big Query API I get the following error:

"Project {project-id-different-to-below} is not found and cannot be used for API calls. (line 16, file "reportModel")"

I don't recognise the project id in the message, it's not the same as the one written into my code. Also before when I authenticated the API by trying to use it, the error message linked me to the relevant console page to enable use of the API, it no longer does this.

This is the relevant part of the code:

  var projectId = '{project-id}';

  var request = {
    query: sql_code,
    useLegacySql : false
  };  

  var queryResults = BigQuery.Jobs.query(request, projectId);

Why is this happening and how can I authenticate the new google sheet file with the API? Also, why is the project id listed in the error message different to the one written in the code?

goose
  • 2,502
  • 6
  • 42
  • 69
  • May I ask whether people up-voting are experiencing the same thing? It might be worth me submitting an issue to the relevant google team. – goose Apr 06 '17 at 06:47
  • 1
    You may want to first check this [suggested solution](http://stackoverflow.com/a/37566391). Check your [Developers Console](https://console.developers.google.com/apis/library?project=mytestproject-163015) and make sure that you have enabled all APIs that you will be using. – Teyam Apr 06 '17 at 11:10
  • Thanks @Teyam - this has already been done though. The sheet I copied from is still working fine. – goose Apr 06 '17 at 11:21

2 Answers2

5

I have managed to resolve this now and I did so by clicking 'Resources->Advanced Google Services'. This had a link to the 'Google API Console', if you follow it the console will have the correct project selected and you can enable the Big Query API.

I couldn't find another way to get the correct project selected, although I'm sure there is one.

goose
  • 2,502
  • 6
  • 42
  • 69
3

Go to the https://script.google.com/home/usersettings and enable 'Google Apps Script API'.

Pawel
  • 41
  • 4