I have this script set up but I am getting a 404 what do I need to do to make sure I can call the API?

const scriptProperties = PropertiesService.getScriptProperties(); function GIdea(keywords = "Demo") {     var accessToken = getOAuthToken();      var CLIENTID = scriptProperties.getProperty('CLIENTID');     var endpoint = 'https://googleads.googleapis.com/v10/customers/' + CLIENTID +'/keywordPlans:generateKeywordIdeas';     var requestBody = {       "customerId": CLIENTID,       "language": "ENGLISH",       "geo_target_constants": [],       "include_adult_keywords": false,       "page_size": 10,       "keyword_plan_network": "GOOGLE_SEARCH_AND_PARTNERS",       "keyword_seed": keywords     };     var options = {       'method': 'post',       'contentType': 'application/json',       'headers': {         'Authorization': 'Bearer ' + accessToken       },       'payload': JSON.stringify(requestBody)     };     var response = UrlFetchApp.fetch(endpoint, options);     var ideas = JSON.parse(response.getContentText());     return ideas; } function getOAuthToken() {   var CLIENTID = scriptProperties.getProperty('CLIENTID');   var SECRETFORADS = scriptProperties.getProperty('SECRETFORADS');   var service = OAuth2.createService('GoogleAds')     .setAuthorizationBaseUrl('https://accounts.google.com/o/oauth2/auth')     .setTokenUrl('https://accounts.google.com/o/oauth2/token')     .setClientId(CLIENTID)     .setClientSecret(SECRETFORADS)     .setScope('https://www.googleapis.com/auth/adwords');   if (!service.hasAccess()) {     return 'No access to Google Ads API';   }   var url = API_URL;   var headers = {     "Authorization": "Bearer " + service.getAccessToken(),     "Content-Type": "application/json",     "muteHttpExceptions": false   };   var options = {     "method": "get",     "headers": headers,   };   var response = UrlFetchApp.fetch(url, options);   var jsonResponse = JSON.parse(response.getContentText());   return jsonResponse } 

Exception: Request failed for https://googleads.googleapis.com returned code 404. Truncated server response: <titl... (use muteHttpExceptions option to examine full response) (line 70).

I call the function in a Google Sheets cell and get a 404 instead of the results of the API call.

Tag:google-ads-api, javascript

Add a new comment.