I'm using OAuth 2.0 Authentication for Adwords API.
I'm running the 'awapi_dotnet_lib_v16.7.0' sample solution (.NET Library)
from google and in the 'AdWords.Examples.CSharp' I have the following tags
set in my app.config file:
<add key="UserAgent" value="xxxxxxxxxxxxxxx"/>
<add key="DeveloperToken" value="xxxxxxxxxxxxxxxxxxx"/>
<add key="ClientCustomerId" value="xxx-xxx-xxxx"/>
<add key="AuthorizationMethod" value="OAuth2" />
<add key="OAuth2ClientId"
value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<add key="OAuth2ClientSecret" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<add key="OAuth2Mode" value="APPLICATION" />
<add key="OAuth2RefreshToken"
value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
I'm able to run the 'GetAccountHierarchy' functionality through command
line (v201402.GetAccountHierarchy) to fetch all the accounts under my MCC
(client centre).
But, when I tries to run the DownloadCriteriaReport
(v201402.DownloadCriteriaReport) to fetch Account Performance Report it
gives me error..
*Message*: Report download errors occurred, see errors field for more
details.
*Source*: Google.AdWords
*Stack Trace*:
at
Google.Api.Ads.AdWords.Util.Reports.ReportUtilities.DownloadReportToStream(String
downloadUrl, Boolean returnMoneyInMicros, String postBody, Stream
outputStream) in c:\src\MyProjects\now\Common library
base\adwords\compile\Util\Reports\ReportUtilities.cs:line 304
at
Google.Api.Ads.AdWords.Util.Reports.ReportUtilities.DownloadClientReportInternal(String
downloadUrl, String postBody, Boolean returnMoneyInMicros, String path) in
c:\src\MyProjects\now\Common library
base\adwords\compile\Util\Reports\ReportUtilities.cs:line 253
at
Google.Api.Ads.AdWords.Util.Reports.ReportUtilities.DownloadClientReport[T](T
reportDefinition, Boolean returnMoneyInMicros, String path) in
c:\src\MyProjects\now\Common library
base\adwords\compile\Util\Reports\ReportUtilities.cs:line 215
at
Google.Api.Ads.AdWords.Util.Reports.ReportUtilities.DownloadClientReport[T](T
reportDefinition, String path) in c:\src\MyProjects\now\Common library
base\adwords\compile\Util\Reports\ReportUtilities.cs:line 195
at
Google.Api.Ads.AdWords.Examples.CSharp.v201402.DownloadCriteriaReport.Run(AdWordsUser
user, String fileName) in
C:\Users\BGS002\Downloads\awapi_dotnet_lib_v16.7.0\examples\csharp\v201402\Reporting\DownloadCriteriaReport.cs:line
112
Here is the image :
<https://lh5.googleusercontent.com/-Q510gf82WMY/UycB7OqdhFI/AAAAAAAAABA/lOf-crSIpMU/s1600/error.JPG>
Here is the code:
public void Run(AdWordsUser user, string fileName) {
ReportDefinition definition = new ReportDefinition();
definition.reportName = "Custom ACCOUNT_PERFORMANCE_REPORT";
definition.reportType =
ReportDefinitionReportType.ACCOUNT_PERFORMANCE_REPORT;
definition.downloadFormat = DownloadFormat.CSV;
definition.dateRangeType = ReportDefinitionDateRangeType.TODAY;
// Create selector.
Selector selector = new Selector();
selector.fields = new string[] {"AdGroupId", "AdGroupName", "Clicks",
"Impressions"};
Predicate predicate = new Predicate();
predicate.field = "Status";
predicate.@operator = PredicateOperator.IN;
predicate.values = new string[] {"ACTIVE", "PAUSED"};
selector.predicates = new Predicate[] {predicate};
definition.selector = selector;
definition.includeZeroImpressions = true;
string filePath = ExampleUtilities.GetHomeDir() +
Path.DirectorySeparatorChar + fileName;
try {
ReportUtilities utilities = new ReportUtilities(user);
utilities.ReportVersion = "v201402";
utilities.DownloadClientReport(definition, filePath);
Console.WriteLine("Report was downloaded to '{0}'.", filePath);
} catch (Exception ex) {
throw new System.ApplicationException("Failed to download report.",
ex);
}
}
I have also tried this on the web example with this code:
protected void OnDownloadReportButtonClick(object sender, EventArgs e) {
ConfigureUserForOAuth();
ReportDefinition definition = new ReportDefinition();
string fileName = "GoogleAdwords.csv";
definition.reportName = "Custom ACCOUNT_PERFORMANCE_REPORT";
definition.reportType =
ReportDefinitionReportType.ACCOUNT_PERFORMANCE_REPORT;
definition.downloadFormat = DownloadFormat.CSV;
definition.dateRangeType = ReportDefinitionDateRangeType.TODAY;
// Create selector.
Selector selector = new Selector();
selector.fields = new string[] {"AccountId"};
definition.selector = selector;
string filePath = "D:\\Adwords" + Path.DirectorySeparatorChar +
fileName;
(user.Config as AdWordsAppConfig).OAuth2RefreshToken =
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
try {
// If you know that your report is small enough to fit in memory,
then
// you can instead use
ReportUtilities utilities = new ReportUtilities(user);
utilities.ReportVersion = "v201402";
ClientReport report = utilities.GetClientReport(definition);
//
// // Get the text report directly if you requested a text format
// // (e.g. xml)
string reportText = report.Text;
//
// // Get the binary report if you requested a binary format
// // (e.g. gzip)
byte[] reportBytes = report.Contents;
//
// // Deflate a zipped binary report for further processing.
string deflatedReportText = Encoding.UTF8.GetString(
MediaUtilities.DeflateGZipData(report.Contents));
utilities.DownloadClientReport(definition, filePath);
} catch (Exception ex) {
throw new System.ApplicationException("Failed to download report.",
ex);
}
Response.AddHeader("content-disposition",
"attachment;filename=report.csv");
Response.WriteFile(filePath);
Response.End();
}
But was getting the following error : Adwords Error -
Web<https://s3.amazonaws.com/uploads.hipchat.com/36514/402858/ppgl3NxEqWxWiy9/AdwordsError.txt>
Please note that i have all settings in my web.config file and was able to
authenticate and also run the 'Get Campaigns' Functionality from the .Net
Example by giving a Customer Id.
The issue is while trying to download the Account Performance Report...
What am I doing wrong in my code...?
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.