facebook-ads-reporting-google-apps-script icon indicating copy to clipboard operation
facebook-ads-reporting-google-apps-script copied to clipboard

Error at line 39

Open zakloh8888 opened this issue 4 years ago • 8 comments

Hi Frederic,

Thanks for a great bit of code.

Unfortunately, I am getting an error at line 39:

const fetchRequest = UrlFetchApp.fetch(url);

in the Export Facebook Ads Data to Google Sheets file.

It worked perfectly until 10 days ago, and then it just stopped. I did not change anything in the set-up or with my account info. I can download the FB data in a CSV with no problems, but the data will not export into the Sheet.

Do you have any ideas what the issue might be?

Thanks

Zak

zakloh8888 avatar Dec 14 '20 14:12 zakloh8888

This is the error: Exception: Unexpected error: https://www.facebook.com/ads/ads_insights/export_report?report_run_id=8777747&format=csv&access_token=EAALZBMeUhHX0 (line 39, file "pastedata_rta")

zakloh8888 avatar Dec 14 '20 14:12 zakloh8888

This is the code for the file:

/** *

  • Export Facebook Ads Data to Google Sheets
  • Pushes the Facebook asynchronous report to Google Sheets
  • Version: 2.2
  • Google Apps Script maintained by Frederic Harnois
  • [email protected]

**/

// MODIFY YOUR SETTINGS HERE //

// url of the google sheets where the report will be const SPREADSHEET_URL = 'https://docs.google.com/spreadsheets/d/1nkluzUdvvxo7FrwAw/edit#gid=0'

// name of the sheet where the report will be const TAB_NAME = 'RTA'

// DO NOT MODIFY ANYTHING BELOW //

function getFacebookReport() {

// Selects the chosen sheet and tab const ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL); const sheet = ss.getSheetByName(TAB_NAME);

// Clears the sheet sheet.clear();

// Gets the Facebook report run ID const cache = CacheService.getScriptCache(); const reportId = cache.get('campaign-report-id');

// Fetches the report as a csv file const url = https://www.facebook.com/ads/ads_insights/export_report?report_run_id=${reportId}&format=csv&access_token=${TOKEN}; const fetchRequest = UrlFetchApp.fetch(url); const results = Utilities.parseCsv(fetchRequest);

// Pastes the csv file in the sheet sheet.getRange(1,1, results.length, results[0].length).setValues(results); }

zakloh8888 avatar Dec 14 '20 14:12 zakloh8888

It's this Google bug: https://issuetracker.google.com/issues/175141974

The fetch part doesn't work with csv files UrlFetchApp.fetch(url); --this doesn't work

Lots of users affected by this, go star the issue

On Mon, Dec 14, 2020 at 9:08 AM zakloh8888 [email protected] wrote:

This is the code for the file:

/** *

  • Export Facebook Ads Data to Google Sheets
  • Pushes the Facebook asynchronous report to Google Sheets
  • Version: 2.2
  • Google Apps Script maintained by Frederic Harnois
  • [email protected]

**/

// MODIFY YOUR SETTINGS HERE //

// url of the google sheets where the report will be const SPREADSHEET_URL = ' https://docs.google.com/spreadsheets/d/1nkluzUdvvxo7FrwAw/edit#gid=0'

// name of the sheet where the report will be const TAB_NAME = 'RTA'

// DO NOT MODIFY ANYTHING BELOW //

function getFacebookReport() {

// Selects the chosen sheet and tab const ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL); const sheet = ss.getSheetByName(TAB_NAME);

// Clears the sheet sheet.clear();

// Gets the Facebook report run ID const cache = CacheService.getScriptCache(); const reportId = cache.get('campaign-report-id');

// Fetches the report as a csv file const url = https://www.facebook.com/ads/ads_insights/export_report?report_run_id=${reportId}&format=csv&access_token=${TOKEN} ; const fetchRequest = UrlFetchApp.fetch(url); const results = Utilities.parseCsv(fetchRequest);

// Pastes the csv file in the sheet sheet.getRange(1,1, results.length, results[0].length).setValues(results); }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fredericharnois/facebook-ads-reporting-google-apps-script/issues/23#issuecomment-744464145, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALP4EBND2LGM6GDQGDEYVATSUYL7DANCNFSM4U2ZL3YQ .

flescobarp avatar Dec 14 '20 14:12 flescobarp

Ah thank you for the reply. So this is affecting you as well? Is there a work around at all?

zakloh8888 avatar Dec 14 '20 14:12 zakloh8888

There are some suggestions in the comments of that issue tracker, and yes, I'm also affected by this. Haven't found anything that helps but ymmv

On Mon, Dec 14, 2020 at 9:30 AM zakloh8888 [email protected] wrote:

Ah thank you for the reply. So this is affecting you as well? Is there a work around at all?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fredericharnois/facebook-ads-reporting-google-apps-script/issues/23#issuecomment-744477850, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALP4EBNSP3IF5DCFHIKIDPTSUYOPHANCNFSM4U2ZL3YQ .

flescobarp avatar Dec 14 '20 14:12 flescobarp

OK, thanks! Back to cut and paste for now :(

zakloh8888 avatar Dec 14 '20 14:12 zakloh8888

Thanks for sharing this. Im also running into the error on line 39. Any work around here?

jgrantneumann avatar Mar 18 '21 18:03 jgrantneumann

I've gotten the same problem

totora123 avatar Jun 22 '21 07:06 totora123