Hello,
I am trying to query the AdWords reporting API using the following Google Scripts code:
var params = {
headers: {
Authorization: 'Bearer ___ACCESS_TOKEN___',
developerToken: '___DEVELOPER_TOKEN___',
clientCustomerId: '___CUSTOMER_ID_XXXXXXXXXX___'
},
muteHttpExceptions: true,
'__rdquery' : 'SELECT CampaignName FROM CAMPAIGN_PERFORMANCE_REPORT DURING LAST_7_DAYS',
'__fmt' : 'CSV',
method:'post'
}
Logger.log(params)
Logger.log(UrlFetchApp.fetch(url, params))
}
The response I get is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownloadError><ApiError><type>ReportDownloadError.MISSING_PARAMETER</type><trigger>Missing report definition</trigger><fieldPath></fieldPath></ApiError></reportDownloadError>
I have tried defining the reports in a number of different ways:
I have tried with and without URL encoding for the __rdquery and for the authorization token.
Could this be an error with my authorization? Or am I failing to define my request correctly?
I could not find a client library with any existing code that works in Google Scripts. If there is a resource I could review for accessing the AdWords API using the UrlFetchApp I would be really appreciative.
Thank you