AdGroupService returns entries on test account, but not on my real account.

64 views
Skip to first unread message

Steven Horton

unread,
May 12, 2017, 2:54:35 PM5/12/17
to AdWords API Forum
I tried post this an hour ago, but it seems as though I must have discarded it. I'm trying to get a list of ad groups, and it works on my test account, but doesn't work on my real account.

On my test account:
[2017-05-12 18:15:11] AW_SOAP.INFO: clientCustomerId= operations=1 service=AdGroupService method=query responseTime=450 requestId=server=adwords.google.com isFault=0 faultMessage=
Found ad group ID #1234567890



On my real account:
[2017-05-12 18:32:32] AW_SOAP.INFO: clientCustomerId= operations=1 service=AdGroupService method=query responseTime=205 requestId= server=adwords.google.com isFault=0 faultMessage=
No entries found for ads groups. \app\Console\Commands\AdwordsSync.php:57

The modified sample code.
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201702\cm\CampaignService;
use Google\AdsApi\AdWords\v201702\cm\AdGroupService;
use Google\AdsApi\AdWords\v201702\cm\AdGroupAdService;
use Google\AdsApi\Common\OAuth2TokenBuilder;
class AdwordsSync extends Command {
    protected $signature = 'Adwords:Sync';
    protected $description = 'Synchronize adwords campaign data';
    protected $session = null;

    public function __construct()
    {
        parent::__construct();
    }
    const PAGE_LIMIT = 500;
    
    public function handle() {
        $oAuth2Credential = (new OAuth2TokenBuilder())
            ->fromFile()
            ->build();

        // Construct an API session configured from a properties file and the OAuth2
        // credentials above.
        $this->session = (new AdWordsSessionBuilder())
            ->fromFile()
            ->withOAuth2Credential($oAuth2Credential)
            ->build();

        $this->adWordsServices = new AdWordsServices();
        $this->adGroupService = $this->adWordsServices->get($this->session, AdGroupService::class);

        $offset = 0;

        $query = 'SELECT Id, Name, Status, CampaignId ORDER BY Id';

            $pageQuery = sprintf('%s LIMIT %d,%d', $query, $offset, self::PAGE_LIMIT);
            // Make the query request.
            $page = $this->adGroupService->query($pageQuery);

            // Display results from the query.
            if ($page->getEntries() !== null) {
                foreach ($page->getEntries() as $adGroup) {
                    $id = $adGroup->getId();
                    printf("Found ad group ID #%s",$id);
                }
            } else {
                echo "No entries found for ads groups. ".__FILE__. ":" . __LINE__ . "\n";
            }
    }
}






Shwetha Vastrad (AdWords API Team)

unread,
May 12, 2017, 4:35:09 PM5/12/17
to AdWords API Forum
Hi Steve, 

Could you enable logging and provide the SOAP request and response logs for the request to your production account? Could you also confirm that you are using the OAuth2 credentials associated with your production account to make this request and that the clientCustomerId used in the request header is for your production client account? Please use Reply privately to author when responding. 

Regards,
Shwetha, AdWords API Team.

Steven Horton

unread,
May 12, 2017, 5:26:36 PM5/12/17
to AdWords API Forum
Will I still be able to upload offline conversions for YouTube campaigns using the API?

Shwetha Vastrad (AdWords API Team)

unread,
May 15, 2017, 10:31:22 AM5/15/17
to AdWords API Forum
Hi Steven, 

You need to create an UploadConversion, and then you can use the OfflineConversionFeedService to upload conversions for clicks. Please see the Importing Click Conversions guide for details. You need to enable auto-tagging for the account using CustomerService or in the UI. Without auto-tagging you won't get the GCLID parameter required to upload conversions corresponding to a click. The UploadOfflineConversions Java example shows how to import offline conversion values for specific clicks to your account. Example code in other languages is available here.
Reply all
Reply to author
Forward
0 new messages