googleads / googleads-dotnet-lib

Google Ad Manager SOAP API .NET client library
Apache License 2.0
108 stars 199 forks source link

Google DFP (AdManager API): While trying to download a Report, an ArgumentNullException is thrown #212

Closed alfonsohdez08 closed 5 years ago

alfonsohdez08 commented 5 years ago

Hey team,

We're using the version 24.2.0 of the Google.Dfp package in our project (.NET framework version is the 4.5.2 one). A job is ran daily for download a report generated from Google DFP (We pass the parameters for generate the report in DFP, and then We download it as a CSV file). This job got a couple of weeks running with no issues, but since yesterday, We're not able to download the reports because some exception thrown by the Google.Dfp library. The exception specifically thrown is a System.ArgumentNullException; check below the whole stack trace and the exception message for a better understanding:

Exception Message: Value cannot be null. Parameter name: requestUriString

Stack Trace:

   at System.Net.WebRequest.Create(String requestUriString) 
   at Google.Api.Ads.Common.Util.HttpUtilities.BuildRequest(String url, String method, AppConfig config)
   at Google.Api.Ads.AdManager.Util.v201811.ReportUtilities.BuildRequest(String downloadUrl)
   at Google.Api.Ads.AdManager.Util.v201811.ReportUtilities.GetReport()
   at Google.Api.Ads.Common.Util.Reports.AdsReportUtilities.GetResponse()

Here's our AdManagerApi config (placed into our project App.Config):

<AdManagerApi>
    <add key="MaskCredentials" value="true" />
    <add key="EnableGzipCompression" value="true" />
    <add key="IncludeUtilitiesInUserAgent" value="true" />
    <add key="ProxyServer" value="" />
    <add key="ProxyUser" value="" />
    <add key="ProxyPassword" value="" />
    <add key="ProxyDomain" value="" />
    <add key="ApplicationName" value="DFP Download" />
    <add key="NetworkCode" value="1234" />
    <add key="OAuth2Mode" value="SERVICE_ACCOUNT" />
    <add key="OAuth2SecretsJsonPath" value="../Config/ServiceAccountKey.json" />
</AdManagerApi>

Also, check below a simple code snippet for see what We're doing basically:

//Report parameters
var startDate = System.DateTime.UtcNow.AddDays(-1);
var endDate = System.DateTime.UtcNow;

//Path where the report would be saved
string savePath = "SOME_PATH";

var dfpUser = new AdManagerUser();
using (var reportService = dfpUser.GetService<ReportService>())
{
    var reportJob = new ReportJob();
    var reportQuery = new ReportQuery();

    //Set report parameters
    reportQuery.dateRangeType = DateRangeType.CUSTOM_DATE;
    reportQuery.startDate = DateTimeUtilities.FromDateTime(startDate.Date, "America/New_York").date;
    reportQuery.endDate = DateTimeUtilities.FromDateTime(endDate.Date, "America/New_York").date;

    //Report attributes
    reportQuery.dimensions = new Dimension[] {Dimension.DATE,Dimension.ADVERTISER_ID, Dimension.ADVERTISER_NAME
        , Dimension.CREATIVE_ID, Dimension.CREATIVE_NAME, Dimension.CREATIVE_SIZE, Dimension.CREATIVE_SIZE_DELIVERED};

    reportQuery.columns = new Column[] { Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.AD_SERVER_CTR};

    reportJob.reportQuery = reportQuery;

    //Report started running
    ReportJob runningReport = reportService.runReportJob(reportJob);
    var reportUtilities = new ReportUtilities(reportService, runningReport.id);

    //Set report download options
    var options = new ReportDownloadOptions();
    options.exportFormat = ExportFormat.CSV_DUMP;
    options.useGzipCompression = false;

    reportUtilities.reportDownloadOptions = options;

    using (var reportResponse = reportUtilities.GetResponse())
    {
        reportResponse.Save(savePath);
    }

}

So the exception is thrown when method reportUtilities.GetResponse() is called.

If there's some additional information that must be provided, please comment it.

Note: the SOAP API version being used it's the v201811.

christopherseeley commented 5 years ago

If you've enabled SOAP logs, can you check and see what the report status was? There's been an issue with Ad Manager reporting for the past ~24 hours: https://ads.google.com/status#hl=en&v=issue&sid=24&iid=18f69caf6758fa14b6f06986d13b1e17

alfonsohdez08 commented 5 years ago

Thanks @christopherseeley! I'll monitor the Ad Manager status dashboard.

However, I enabled SOAP logs, where log level is verbose. The SOAP operation getReportJobStatus it's called multiple times; all operation's responses is IN_PROGRESS, except the last one where the status's response is empty. After all getReportJobStatus operation calls, there's a last call for download the report: getReportDownloadUrlWithOptions, and its response is empty as well.

Summary Logs

AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: runReportJob, networkCode: 1234, Request ID: 5d644e4274df8156179ce65ec86f0c3e, ResponseTime(ms): 764, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: c9e5129232e3666513353a3609722469, ResponseTime(ms): 402, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 1e644b07d10944798b47f3ace918e464, ResponseTime(ms): 496, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 0361e854433f4c8b7d34824f2e8e4f60, ResponseTime(ms): 149, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 0543cff965e478e765b88a67984b57a6, ResponseTime(ms): 128, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 172735dc274984916206e51454ac9195, ResponseTime(ms): 296, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 7c9e0dc3c68ce5d2030cc4096e83d5ed, ResponseTime(ms): 293, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 902d9a5386589efd9da31cdf562f3456, ResponseTime(ms): 251, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 20b7f9d84eecbb815375e07e14ea8aec, ResponseTime(ms): 251, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 5a85cdc8164533d3dcd89f0b3cf0ed5d, ResponseTime(ms): 257, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 13009d28f4814f83cbdd7098a017af0e, ResponseTime(ms): 222, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 6782f75c30e08d782103435b18e7eecd, ResponseTime(ms): 263, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 5e68a3635230cf8e2458855e26dad26d, ResponseTime(ms): 263, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 4103cdcfc752b22e10442b66f835476c, ResponseTime(ms): 240, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: db7c5a8dcc6ad4d917adb1dca21f4c11, ResponseTime(ms): 289, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: d17eee3d83ef605f4e27e464e218c7c2, ResponseTime(ms): 250, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 598509c6321a21cd37b4d000889281d6, ResponseTime(ms): 148, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportJobStatus, networkCode: 1234, Request ID: 96e148b127fe10af97cbe337465342db, ResponseTime(ms): 16, OperationsCount: 0, IsFault: False, FaultMessage: 
AdsClientLibs.SummaryRequestLogs Information: 1 : Request made: Host: ads.google.com, Service: ReportService, Method: getReportDownloadUrlWithOptions, networkCode: 1234, Request ID: fdfef5bab5546966abb6d7a737f069a6, ResponseTime(ms): 17, OperationsCount: 0, IsFault: False, FaultMessage: 

Detailed Logs (the last 3 SOAP calls)

-----------------BEGIN API CALL---------------------

Request
-------

POST /apis/ads/publisher/v201811/ReportService
VsDebuggerCausalityData: uIDPo2kPPqB9SatIv0eyiL2u19IAAAAAtZP0cchSCEiXidhe+ASWxo7Vprh/uChCjivOIfXnXY4ACQAA
Authorization: REDACTED
Accept-Encoding: gzip, deflate
TimeStamp: Tue, 14 May 2019 14:09:51 GMT

<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <RequestHeader xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <networkCode>1234</networkCode>
      <applicationName>DFP Download (AdManagerApi-DotNet/24.2.0, Common-Dotnet/9.4.0, .NET CLR/4.0.30319.42000, Logging, OAuthServiceAccountFlow, gzip)</applicationName>
    </RequestHeader>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <getReportJobStatus xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <reportJobId>123456</reportJobId>
    </getReportJobStatus>
  </s:Body>
</s:Envelope>

Response
--------

Content-Encoding: 
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Alt-Svc: quic=":443"; ma=2592000; v="46,44,43,39"
Transfer-Encoding: chunked
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=UTF-8
Date: Tue, 14 May 2019 18:09:51 GMT
Expires: Tue, 14 May 2019 18:09:51 GMT
Server: GSE
TimeStamp: Tue, 14 May 2019 14:09:51 GMT

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <requestId>598509c6321a21cd37b4d000889281d6</requestId>
      <responseTime>148</responseTime>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <getReportJobStatusResponse xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <rval>IN_PROGRESS</rval>
    </getReportJobStatusResponse>
  </soap:Body>
</soap:Envelope>
-----------------END API CALL-----------------------

AdsClientLibs.DetailedRequestLogs Verbose: 1 : 
-----------------BEGIN API CALL---------------------

Request
-------

POST /apis/ads/publisher/v201811/ReportService
VsDebuggerCausalityData: uIDPo2oPPqB9SatIv0eyiL2u19IAAAAAtZP0cchSCEiXidhe+ASWxo7Vprh/uChCjivOIfXnXY4ACQAA
Authorization: REDACTED
Accept-Encoding: gzip, deflate
TimeStamp: Tue, 14 May 2019 14:10:22 GMT

<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <RequestHeader xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <networkCode>1234</networkCode>
      <applicationName>DFP Download (AdManagerApi-DotNet/24.2.0, Common-Dotnet/9.4.0, .NET CLR/4.0.30319.42000, Logging, OAuthServiceAccountFlow, gzip)</applicationName>
    </RequestHeader>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <getReportJobStatus xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <reportJobId>123456</reportJobId>
    </getReportJobStatus>
  </s:Body>
</s:Envelope>

Response
--------

Content-Encoding: 
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Alt-Svc: quic=":443"; ma=2592000; v="46,44,43,39"
Transfer-Encoding: chunked
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=UTF-8
Date: Tue, 14 May 2019 18:10:22 GMT
Expires: Tue, 14 May 2019 18:10:22 GMT
Server: GSE
TimeStamp: Tue, 14 May 2019 14:10:22 GMT

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <requestId>96e148b127fe10af97cbe337465342db</requestId>
      <responseTime>16</responseTime>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <getReportJobStatusResponse xmlns="https://www.google.com/apis/ads/publisher/v201811"></getReportJobStatusResponse>
  </soap:Body>
</soap:Envelope>
-----------------END API CALL-----------------------

AdsClientLibs.DetailedRequestLogs Verbose: 1 : 
-----------------BEGIN API CALL---------------------

Request
-------

POST /apis/ads/publisher/v201811/ReportService
VsDebuggerCausalityData: uIDPo2sPPqB9SatIv0eyiL2u19IAAAAAtZP0cchSCEiXidhe+ASWxo7Vprh/uChCjivOIfXnXY4ACQAA
Authorization: REDACTED
Accept-Encoding: gzip, deflate
TimeStamp: Tue, 14 May 2019 14:10:22 GMT

<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <RequestHeader xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <networkCode>1234</networkCode>
      <applicationName>DFP Download (AdManagerApi-DotNet/24.2.0, Common-Dotnet/9.4.0, .NET CLR/4.0.30319.42000, Logging, OAuthServiceAccountFlow, gzip)</applicationName>
    </RequestHeader>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <getReportDownloadUrlWithOptions xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <reportJobId>123456</reportJobId>
      <reportDownloadOptions>
        <exportFormat>CSV_DUMP</exportFormat>
        <useGzipCompression>false</useGzipCompression>
      </reportDownloadOptions>
    </getReportDownloadUrlWithOptions>
  </s:Body>
</s:Envelope>

Response
--------

Content-Encoding: 
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Alt-Svc: quic=":443"; ma=2592000; v="46,44,43,39"
Transfer-Encoding: chunked
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=UTF-8
Date: Tue, 14 May 2019 18:10:22 GMT
Expires: Tue, 14 May 2019 18:10:22 GMT
Server: GSE
TimeStamp: Tue, 14 May 2019 14:10:22 GMT

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201811">
      <requestId>fdfef5bab5546966abb6d7a737f069a6</requestId>
      <responseTime>17</responseTime>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <getReportDownloadUrlWithOptionsResponse xmlns="https://www.google.com/apis/ads/publisher/v201811"></getReportDownloadUrlWithOptionsResponse>
  </soap:Body>
</soap:Envelope>
-----------------END API CALL-----------------------
alfonsohdez08 commented 5 years ago

Closing this issue because it was an intermittent problem from the Google Ad Manager platform.

Thanks for the support!