adwords api reporting <trigger>Missing client information</trigger>

670 views
Skip to first unread message

jane

unread,
May 22, 2017, 9:29:07 AM5/22/17
to AdWords API Forum
I'm sorry if someone has posted similar problem already, I just can't figure it out.
I'm trying to get daily costs of my campaigns.
I use this documentation https://developers.google.com/adwords/api/docs/guides/reporting

I am also using php and Yii2. I've got:

client Customer Id

client id    
 access token   
 client_secret

refresh_token  

When I get Campaigns names and ids, those client Customer Id,client id,client_secret are enough and I get campaigns without any problem but when I try to get a report, there is the error

    string(581) "HTTP/1.1 400 Bad Request
    Content-Type: text/xml
    Date: Mon, 22 May 2017 10:31:52 GMT
    Expires: Mon, 22 May 2017 10:31:52 GMT
    Cache-Control: private, max-age=0
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1; mode=block
    Server: GSE
    Accept-Ranges: none
    Vary: Accept-Encoding
    Transfer-Encoding: chunked
   
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownloadError><ApiError><type>ReportDownloadError.INVALID_PARAMETER</type><trigger>Missing client information</trigger><fieldPath></fieldPath></ApiError></reportDownloadError>"

Maybe I make post request with curl wrong, since I'm able to get campaigns without mistakes.
Here is my code

    $ch = curl_init();
   
            curl_setopt($ch, CURLOPT_URL,"http://adwords.google.com/api/adwords/reportdownload/v201702");
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch,CURLOPT_HEADER,1);
   
    $XML= <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201702">
        <selector>
            <fields>CampaignId</fields>
            <fields>AdGroupId</fields>
            <fields>Impressions</fields>
            <fields>Clicks</fields>
            <fields>Cost</fields>
            <predicates>
                <field>AdGroupStatus</field>
                <operator>IN</operator>
                <values>ENABLED</values>
                <values>PAUSED</values>
            </predicates>
        </selector>
        <reportName>Custom Adgroup Performance Report</reportName>
        <reportType>ADGROUP_PERFORMANCE_REPORT</reportType>
        <dateRangeType>TODAY</dateRangeType>
        <downloadFormat>CSV</downloadFormat>
    </reportDefinition>
    XML;
   
    $headers = array("Content-Type:multipart/form-data",
     "Authorization"=> "Bearer my_access_token",
      "developerToken" => "my_developer_token",
     "clientCustomerId"=> 111-111-1111, // test account
   
    );
   
    $postfields = array("__rdxml" =>$XML );
            curl_setopt($ch, CURLOPT_HTTPHEADER , $headers);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
   
   
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   
            $server_output = curl_exec ($ch);
     echo "<pre>";
    var_dump($server_output);
    echo "</pre>";
            curl_close ($ch);

I also tried
$campaignService = $ADwordsUser->GetService('CampaignService', ADWORDS_VERSION);

// Create selector.
$selector = new Selector();
// Fields to retrieve
$selector->fields = array('Id', 'Name', 'Cost');
// Date rage for stats
$selector->dateRange->min = "20110613";
$selector->dateRange->max = "20110614";

// Get all campaigns.
$page = $campaignService->get($selector);

if(isset($page->entries)){
foreach ($page->entries as $campaign) {
if(isset($campaign->campaignStats)) {
// This is how you get the cost
$cost = $campaign->campaignStats->cost->microAmount/1000000;
print "Cost for Campaign {$campaign->name} = $cost\n";
}
}
}


but it returns

Creating default object from empty value

when it goes here
$selector->dateRange->min = "20110613";

, I guess because $selector is null...

But if I remove


$selector->dateRange->min = "20110613";
$selector->dateRange->max = "20110614";

I get

[SelectorError.INVALID_FIELD_NAME @ serviceSelector; trigger:'Cost']


And I'm also not sure if

$campaign->campaignStats

exists...


Thank you to anyone who can help.

Sreelakshmi Sasidharan (AdWords API Team)

unread,
May 22, 2017, 2:27:38 PM5/22/17
to AdWords API Forum
Hi Jane, 

Regarding the first error : "Missing client information", how are you setting the clientCustomerId and the OAuth token(s) while making the report request? The error usually occurs when there is an issue with the client information passed in the request header. Also, please make sure that the OAuth tokens being used belongs to the same customer login. Could you Reply privately to author with the configuration file so that I can take a closer look? Also, are you using our PHP client library

Regarding the second error : "INVALID_FIELD_NAME", please note that 'Cost' is not a valid selector field for CampaignService. Please check here for all the available fields that you can use for CampaignService.get(). To get the 'cost' and other performance stats, you could use the Campaign Performance Report. To get the status of the campaign using CampaignService, you will need to specify the 'status' field in the selector. 

Thanks,
Sreelakshmi, AdWords API Team
Reply all
Reply to author
Forward
0 new messages