0
const { OAuth2Client } = require('google-auth-library');
const request = require('request');

const API_VERSION = 'v13';
const customer_id = '1234567890';
const developer_token = 'my-developer-token';
const access_token = 'my-access-token';

const client = new GoogleAdsApi({
    client_id: CLIENT_ID,
    client_secret: CLIENT_SECRET,
    developer_token: developer_token
});

const options = {
            url: `https://googleads.googleapis.com/${API_VERSION}/customers/${customer_id}/googleAds:searchStream`,
            headers: {
              'Authorization': `Bearer ${access_token}`,
              'developer-token': developer_token,
              'login-customer-id': customer_id,
              'Content-Type': 'application/json'
            },
            body: JSON.stringify({
              query: `SELECT campaign.id, campaign.name 
              FROM campaign 
              WHERE campaign.status = 'ENABLED'`
            })
          };

request.post(options, (error, response, body) => {
  if (error) {
    console.error(error);
    return;
  }
  console.log(JSON.parse(body));
});

The response I get is an empty array, even though I have campaigns in my Google Ads account that match the query. I'm not getting any error messages, so I'm not sure what's going wrong.

0 Answers0