Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Getting Error 403: Forbidden when downloading Report using DownloadReportToFile

71 views
Skip to first unread message

B Sangappa

unread,
Mar 11, 2025, 5:57:48 AMMar 11
to Google Ad Manager API Forum
Hi Team,
We are facing issue when downloading the Excel/CSV GAM Report through DownloadReportToFile.
issue we are facing: HTTPError:HTTP Error 403: Forbidden
Request:
statement = (ad_manager.StatementBuilder(version='v202411')
                .Where("ORDER_ID = :orderId")
                .WithBindVariable('orderId', orderId)
                .Limit(None)
                .Offset(None))

report_job = {
        'reportQuery': {
            'dimensions': ['LINE_ITEM_NAME', 'CREATIVE_NAME'],
            'adUnitView': 'HIERARCHICAL',
            'statement': statement.ToStatement(),
            'columns': ['AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS'],
            'dateRangeType': 'CUSTOM_DATE',
            'startDate' : startDateForWhichRunReport,
            'endDate' : endDateForWhichRunReport
        }
    }

report_downloader = client.GetDataDownloader(version='v202411')
retryCount = 0
report_job_id = None
while (retryCount < 5) and (report_job_id is None):
    try:
        report_job_id = report_downloader.WaitForReport(report_job)
    except Exception as inst:
        error = inst.args
        error = str(error)
        print('Error Occured While Generating the Reprot for the Order ',orderId,', Error is:', error)
        retryCount += 1

 reportFilePath = 'orderReport'
if not os.path.exists(reportFilePath):
    print('Creating Folder for Order Level Report Files')
    os.makedirs(reportFilePath)

report_file = tempfile.NamedTemporaryFile(dir=reportFilePath, suffix='.xlsx', delete=False)
report_downloader.DownloadReportToFile(
    report_job_id=report_job_id,
    export_format='XLSX',
    outfile=report_file,
    use_gzip_compression=False
)
reportFileAndPath = report_file.name


We are getting error(HTTPError:HTTP Error 403: Forbidden) in line report_downloader.DownloadReportToFile , could you please help us with this, as it is blocking our business requirement.

We Ran this in Airflow and Dataproc Batches.


Below you can find the request details,

2025-03-11 07:53:22,939 - googleads.soap - INFO - Request made: Service: "ReportService" Method: "runReportJob" URL: "https://ads.google.com/apis/ads/publisher/v202408/ReportService"
2025-03-11 07:53:22,939 - googleads.soap - DEBUG - Outgoing request: {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=utf-8', 'authorization': 'REDACTED'}
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header>
    <ns0:RequestHeader xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408">
      <ns0:networkCode>{Network_Code}</ns0:networkCode>
      <ns0:applicationName>lowes_mnp_admanager (DfpApi-Python, googleads/40.0.0, Python/3.11.0, StatementBuilder, zeep)</ns0:applicationName>
    </ns0:RequestHeader>
  </soap-env:Header>
  <soap-env:Body>
    <ns0:runReportJob xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408">
      <ns0:reportJob>
        <ns0:reportQuery>
          <ns0:dimensions>DATE</ns0:dimensions>
          <ns0:dimensions>ADVERTISER_NAME</ns0:dimensions>
          <ns0:dimensions>AD_UNIT_NAME</ns0:dimensions>
          <ns0:dimensions>CUSTOM_CRITERIA</ns0:dimensions>
          <ns0:adUnitView>HIERARCHICAL</ns0:adUnitView>
          <ns0:columns>AD_SERVER_IMPRESSIONS</ns0:columns>
          <ns0:columns>AD_SERVER_CLICKS</ns0:columns>
          <ns0:columns>AD_SERVER_CTR</ns0:columns>
          <ns0:startDate>
            <ns0:year>2025</ns0:year>
            <ns0:month>3</ns0:month>
            <ns0:day>3</ns0:day>
          </ns0:startDate>
          <ns0:endDate>
            <ns0:year>2025</ns0:year>
            <ns0:month>3</ns0:month>
            <ns0:day>10</ns0:day>
          </ns0:endDate>
          <ns0:dateRangeType>CUSTOM_DATE</ns0:dateRangeType>
          <ns0:statement>
            <ns0:query>WHERE CUSTOM_TARGETING_VALUE_ID IN ({CUSTOM_TARGETING_VALUE_IDs}) AND NOT ADVERTISER_ID IN ({Advertiser_IDS})</ns0:query>
          </ns0:statement>
        </ns0:reportQuery>
      </ns0:reportJob>
    </ns0:runReportJob>
  </soap-env:Body>
</soap-env:Envelope>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\n  <soap:Header>\n    <ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v202408">\n      <requestId>b2bb19407c5f6f393945ddd35dd0d884</requestId>\n      <responseTime>75</responseTime>\n    </ResponseHeader>\n  </soap:Header>\n  <soap:Body>\n    <getReportJobStatusResponse xmlns="https://www.google.com/apis/ads/publisher/v202408">\n      <rval>COMPLETED</rval>\n    </getReportJobStatusResponse>\n  </soap:Body>\n</soap:Envelope>\n'
2025-03-11 07:53:53,689 - googleads.ad_manager.data_downloader - DEBUG - Report has completed successfully
2025-03-11 07:53:53,689 - root - INFO - AdUnitLevel Report generated.
2025-03-11 07:53:53,689 - root - INFO - AdUnitLevel Report Job ID is: 15524469248
2025-03-11 07:53:53,689 - root - INFO - Report File Path is: AdUnitLevel
2025-03-11 07:53:53,690 - googleads.soap - INFO - Request made: Service: "ReportService" Method: "getReportDownloadUrlWithOptions" URL: "https://ads.google.com/apis/ads/publisher/v202408/ReportService"
2025-03-11 07:53:53,690 - googleads.soap - DEBUG - Outgoing request: {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=utf-8', 'authorization': 'REDACTED'
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header>
    <ns0:RequestHeader xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408">
      <ns0:networkCode>{Network_Code}</ns0:networkCode>
      <ns0:applicationName>mnp_admanager (DfpApi-Python, googleads/40.0.0, Python/3.11.0, zeep)</ns0:applicationName>
    </ns0:RequestHeader>
  </soap-env:Header>
  <soap-env:Body>
    <ns0:getReportJobStatus xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408">
      <ns0:reportJobId>15524469248</ns0:reportJobId>
    </ns0:getReportJobStatus>
  </soap-env:Body>
</soap-env:Envelope>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\n  <soap:Header>\n    <ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v202408">\n      <requestId>19afa272dd37f2dc1d8fe463fa34559a</requestId>\n      <responseTime>55</responseTime>\n    </ResponseHeader>\n  </soap:Header>\n  <soap:Body>\n    <getReportJobStatusResponse xmlns="https://www.google.com/apis/ads/publisher/v202408">\n      <rval>IN_PROGRESS</rval>\n    </getReportJobStatusResponse>\n  </soap:Body>\n</soap:Envelope>\n'
2025-03-11 07:53:23,552 - googleads.ad_manager.data_downloader - DEBUG - Report job status: IN_PROGRESS
2025-03-11 07:53:53,553 - googleads.soap - INFO - Request made: Service: "ReportService" Method: "getReportJobStatus" URL: "https://ads.google.com/apis/ads/publisher/v202408/ReportService"
2025-03-11 07:53:53,553 - googleads.soap - DEBUG - Outgoing request: {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=utf-8', 'authorization': 'REDACTED'}
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header>
    <ns0:RequestHeader xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408">
      <ns0:networkCode>{Network_Code}</ns0:networkCode>
      <ns0:applicationName>lowes_mnp_admanager (DfpApi-Python, googleads/40.0.0, Python/3.11.0, zeep)</ns0:applicationName>
    </ns0:RequestHeader>
  </soap-env:Header>
  <soap-env:Body>
    <ns0:getReportDownloadUrlWithOptions xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408">
      <ns0:reportJobId>15524469248</ns0:reportJobId>
      <ns0:reportDownloadOptions>
        <ns0:exportFormat>XLSX</ns0:exportFormat>
        <ns0:includeReportProperties>false</ns0:includeReportProperties>
        <ns0:includeTotalsRow>true</ns0:includeTotalsRow>
        <ns0:useGzipCompression>false</ns0:useGzipCompression>
      </ns0:reportDownloadOptions>
    </ns0:getReportDownloadUrlWithOptions>
  </soap-env:Body>
</soap-env:Envelope>

2025-03-11 07:53:53,690 - zeep.transports - DEBUG - HTTP Post to https://ads.google.com/apis/ads/publisher/v202408/ReportService:
<?xml version='1.0' encoding='utf-8'?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header><ns0:RequestHeader xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408"><ns0:networkCode>{network_code}</ns0:networkCode><ns0:applicationName>lowes_mnp_admanager (DfpApi-Python, googleads/40.0.0, Python/3.11.0, zeep)</ns0:applicationName></ns0:RequestHeader></soap-env:Header><soap-env:Body><ns0:getReportDownloadUrlWithOptions xmlns:ns0="https://www.google.com/apis/ads/publisher/v202408"><ns0:reportJobId>15524469248</ns0:reportJobId><ns0:reportDownloadOptions><ns0:exportFormat>XLSX</ns0:exportFormat><ns0:includeReportProperties>false</ns0:includeReportProperties><ns0:includeTotalsRow>true</ns0:includeTotalsRow><ns0:useGzipCompression>false</ns0:useGzipCompression></ns0:reportDownloadOptions></ns0:getReportDownloadUrlWithOptions></soap-env:Body></soap-env:Envelope>
2025-03-11 07:55:23,289 - urllib3.connectionpool - DEBUG - https://ads.google.com:443 "POST /apis/ads/publisher/v202408/ReportService HTTP/1.1" 200 None
2025-03-11 07:55:23,290 - zeep.transports - DEBUG - HTTP Response from https://ads.google.com/apis/ads/publisher/v202408/ReportService (status: 200):
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v202408"><requestId>b2f9b75865040c460593c1ebd8c80983</requestId><responseTime>89429</responseTime></ResponseHeader></soap:Header><soap:Body><getReportDownloadUrlWithOptionsResponse xmlns="https://www.google.com/apis/ads/publisher/v202408"><rval>https://storage.googleapis.com/dfp-report-export/{Network_Code}-{ID}?GoogleAccessId=googleA...@developer.gserviceaccount.com&amp;Expires=1741680023&amp;Signature=0GZ4gHy6AG%2BFWcaZiBa2NCyKRFBH939842PWuZCWWj9XCXzX8v/AX68OS%2BNp6pL3DaZsNE038L9wj0wOaddvQ8ypvNROUftpfCc8llucSGsxaUzD7yZKSms7MVin7rahTdBRR/Zf015nG0Qe%2B0WbZ5YSmX55iYFYUORglhre%2BEDe7H791t5pdwRMtrx1opuEtCyCzcVZFC%2BW22xDx8y3kiTz24VPnu2Ebv68JawBNHqdVvItABEghZPZ/acxLL8M1D%2B9/8rYANZGS0hqWj3nHGSj6Len1NAavzFpVY8WiJ4Uln2mO34opA1ZxouX3G/szusNySvOcbeHVmFKPQbYJA%3D%3D</rval></getReportDownloadUrlWithOptionsResponse></soap:Body></soap:Envelope>
2025-03-11 07:55:23,290 - googleads.soap - DEBUG - Incoming response:
b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\n  <soap:Header>\n    <ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v202408">\n      <requestId>b2f9b75865040c460593c1ebd8c80983</requestId>\n      <responseTime>89429</responseTime>\n    </ResponseHeader>\n  </soap:Header>\n  <soap:Body>\n    <getReportDownloadUrlWithOptionsResponse xmlns="https://www.google.com/apis/ads/publisher/v202408">\n      <rval>https://storage.googleapis.com/dfp-report-export/{Network_Code}-{ID}?GoogleAccessId=googleA...@developer.gserviceaccount.com&amp;Expires=1741680023&amp;Signature=0GZ4gHy6AG%2BFWcaZiBa2NCyKRFBH939842PWuZCWWj9XCXzX8v/AX68OS%2BNp6pL3DaZsNE038L9wj0wOaddvQ8ypvNROUftpfCc8llucSGsxaUzD7yZKSms7MVin7rahTdBRR/Zf015nG0Qe%2B0WbZ5YSmX55iYFYUORglhre%2BEDe7H791t5pdwRMtrx1opuEtCyCzcVZFC%2BW22xDx8y3kiTz24VPnu2Ebv68JawBNHqdVvItABEghZPZ/acxLL8M1D%2B9/8rYANZGS0hqWj3nHGSj6Len1NAavzFpVY8WiJ4Uln2mO34opA1ZxouX3G/szusNySvOcbeHVmFKPQbYJA%3D%3D</rval>\n    </getReportDownloadUrlWithOptionsResponse>\n  </soap:Body>\n</soap:Envelope>\n'
2025-03-11 07:55:23,291 - googleads.ad_manager.data_downloader - INFO - Request Summary: Report job ID: 15524469248, {'exportFormat': 'XLSX', 'includeReportProperties': False, 'includeTotalsRow': True, 'useGzipCompression': False}
2025-03-11 07:55:23,291 - googleads.ad_manager.data_downloader - INFO - Report URL: https://storage.googleapis.com/dfp-report-export/{Network_Code}-{ID}?GoogleAccessId=googleA...@developer.gserviceaccount.com&Expires=1741680023&Signature=0GZ4gHy6AG%2BFWcaZiBa2NCyKRFBH939842PWuZCWWj9XCXzX8v/AX68OS%2BNp6pL3DaZsNE038L9wj0wOaddvQ8ypvNROUftpfCc8llucSGsxaUzD7yZKSms7MVin7rahTdBRR/Zf015nG0Qe%2B0WbZ5YSmX55iYFYUORglhre%2BEDe7H791t5pdwRMtrx1opuEtCyCzcVZFC%2BW22xDx8y3kiTz24VPnu2Ebv68JawBNHqdVvItABEghZPZ/acxLL8M1D%2B9/8rYANZGS0hqWj3nHGSj6Len1NAavzFpVY8WiJ4Uln2mO34opA1ZxouX3G/szusNySvOcbeHVmFKPQbYJA%3D%3D
2025-03-11 07:55:23,329 ERROR: gam_api.py: HTTPError:HTTP Error 403: Forbidden
2025-03-11 07:55:23,329 - src.main.utils.app_util - ERROR - HTTPError:HTTP Error 403: Forbidden

Ad Manager API Forum Advisor

unread,
Mar 11, 2025, 9:08:15 AMMar 11
to b.san...@lowes.com, google-doubleclick...@googlegroups.com

Hi,

Thank you for contacting the Ad Manager API support team.

On assessing your query, I understand you encountered “403 forbidden error” while using “getReportDownloadUrlWithOptions”. Are you trying to download the report using the same credentials that were used to create it, or are you using different credentials?

To investigate the issue further, please provide the following information.

 

Thanks,
 
Google Logo Ad Manager API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-03-11 13:07:56Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH8Ws:ref" (ADR-00293332)



Reply all
Reply to author
Forward
0 new messages