Can anyone please help me with diagnosing why the API endpoint is returning a 404 error despite proper configuration?
So far, I've tried:
- Verifying correct project configuration
- Confirmed API is enabled
- Recreated OAuth credentials
-
Tried testing with simple GAQL query to fetch campaign data
My problem:
- Every API call results in a 404 (Not Found) error
- Tested multiple API versions (v14, v15, v16, v17, v18 and v19)
- API is confirmed as enabled in Google Cloud Console
- OAuth authentication completes successfully
- My developer token is valid (Basic)
- Customer ID is correctly formatted (no hyphens)
- I have a manager account (correctly formatted too)
- I added my script below, with auth. codes redacted.
I am not a coder by profession and I use Claude Sonnet to get me this far. Ironically, the script for Google Analytics performs flawlessly - I thought this would be "easy" too but I hit a brick wall with the script being unable to move beyond the 404./
// Account info
const MANAGER_ID = '000000000'; // Manager Account ID
const CUSTOMER_ID = '000000000'; // Customer ID
const DEVELOPER_TOKEN = '000000000'; // Your developer token
function testGoogleAdsApiConnection() {
// Simple GAQL query to fetch one campaign
const query = `
SELECT
FROM campaign
LIMIT 1
`;
try {
const response = UrlFetchApp.fetch(url, {
method: 'post',
headers: {
'developer-token': DEVELOPER_TOKEN,
'login-customer-id': MANAGER_ID,
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + ScriptApp.getOAuthToken()
},
payload: JSON.stringify({
query: query
}),
muteHttpExceptions: true
});
// Log the response
Logger.log('Response Code: ' + response.getResponseCode());
Logger.log('Response Content: ' + response.getContentText());
} catch (e) {
Logger.log('Error: ' + e.toString());
}
}