Weather Script Error - returned code 404. Truncated server response: {"cod":"404","message":"city not found"} (use muteHttpExceptions option to examine full response)

1,637 views
Skip to first unread message

Patrick Moore

unread,
Jun 11, 2020, 6:27:04 AM6/11/20
to Google Ads Scripts Forum
Hi,

I have the error on the script log: 
11/06/2020 00:23:01Request failed for http://api.openweathermap.org returned code 404. Truncated server response: {"cod":"404","message":"city not found"} (use muteHttpExceptions option to examine full response) (file Code.gs, line 392)

I don't know how to locate the city it cannot find. Are you able to advise? Will this mean it can't make adjustments to the other cities?

Thanks,

Patrick

Google Ads Scripts Forum Advisor

unread,
Jun 11, 2020, 1:14:44 PM6/11/20
to adwords-scripts+apn2wqdmc6mwrip1...@googlegroups.com, adwords-scripts+apn2wqdmc6mwrip1...@googlegroups.co, adwords...@googlegroups.com
Hi Patrick,

You can insert the following code at line 392 to log the city that is not being found by the API. Please see the code changes in bold:
  var url = Utilities.formatString(
      'http://api.openweathermap.org/data/2.5/weather?APPID=%s&q=%s',
      encodeURIComponent(OPEN_WEATHER_MAP_API_KEY),
      encodeURIComponent(location));

  try {
    var response = UrlFetchApp.fetch(url);
  }
  
  catch(e) {
    Logger.log("City not found: " + location);
  }

  if (response.getResponseCode() != 200) {

Regards,
Matt
Google Ads Scripts Team
 

ref:_00D1U1174p._5004Q20Y2O7:ref

Patrick Moore

unread,
Jun 12, 2020, 8:44:05 AM6/12/20
to Google Ads Scripts Forum on behalf of adsscriptsforumadvisor, adwords-scripts+apn2wqdmc6mwrip1...@googlegroups.com, adwords-scripts+apn2wqdmc6mwrip1...@googlegroups.co
Thanks for getting back to me. It says syntax error with line: catch(e) { 

See below. Have I copied wrong?
image.png

Thanks

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/qLfQzFD0nvw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/PlzJy000000000000000000000000000000000000000000000QBRUKA00X_aGam73QG-HvnVWHjE_Ag%40sfdc.net.


--
-- 
 
Patrick Moore  PPC Strategist
Genie Goals
Sign up for our newsletter

(+44) 1223 324423
Genie Goals, Carlyle House, Carlyle Road, Cambridge. CB4 3DN


Patrick Moore

unread,
Jun 12, 2020, 8:51:00 AM6/12/20
to Google Ads Scripts Forum on behalf of adsscriptsforumadvisor, adwords-scripts+apn2wqdmc6mwrip1...@googlegroups.com, adwords-scripts+apn2wqdmc6mwrip1...@googlegroups.co
Hi, I tried with the 'try' and it seems to have worked. Didn't realise that was part of it.

Reply all
Reply to author
Forward
0 new messages