BingAds / BingAds-Python-SDK

Other
116 stars 162 forks source link

AdGroupPerformanceReportColumn returns "Type not found: 'AccountName'" #69

Closed ilkkapeltola closed 6 years ago

ilkkapeltola commented 6 years ago

I can get the 'report_request.py' script to work just fine. But when I try to run an Ad Group Performance Report, suds returns the error Type not found: 'AccountName'

def get_adgroup_performance_report_request():

    report_request=reporting_service.factory.create('AdGroupPerformanceReportColumn')
    report_request.Format=REPORT_FILE_FORMAT
    report_request.ReportName='My Ad Group Performance Report'
    report_request.ReturnOnlyCompleteData=False
    report_request.Aggregation='Daily'
    report_request.Language='English'

    scope=reporting_service.factory.create('AccountThroughAdGroupReportScope')
    scope.AccountIds={'long': [authorization_data.account_id] }
    scope.Campaigns=None
    scope.AdGroups=None

    report_request.Scope=scope
    report_time=reporting_service.factory.create('ReportTime')

    report_time.PredefinedTime='LastFourWeeks'
    report_request.Time=report_time

    report_columns=reporting_service.factory.create('ArrayOfAdGroupPerformanceReportColumn')
    report_columns.AdGroupPerformanceReportColumn.append([
        'AccountName'
        'TimePeriod',
        'AccountId',
        'AdGroupId',
        'AdGroupName',
        'CampaignId',
        'CampaignName',
        'Clicks',
        'Impressions',
        'Ctr',
        'AverageCpc',
        'Spend',
        'QualityScore'
    ])
    report_request.Columns=report_columns

    return report_request

Then I pass the report_request to ReportingDownloadParameters, like it is done in the example.

    report_request = get_adgroup_performance_report_request()

    reporting_download_parameters = ReportingDownloadParameters(
        report_request=report_request,
        result_file_directory = FILE_DIRECTORY, 
        result_file_name = DOWNLOAD_FILE_NAME, 
        overwrite_result_file = True, # Set this value true if you want to overwrite the same file.
        timeout_in_milliseconds=3600000 # You may optionally cancel the download after a specified time interval.
    )

    result_file_path = reporting_service_manager.download_file(reporting_download_parameters)
    print("Download result file: {0}\n".format(result_file_path))

I've been able to get the CampaignPerformanceReport to work just fine, and the examples work too, but for some reason this AdGroupPerformanceReport does not. Is it an issue with the BingAds SDK, or suds?

ilkkapeltola commented 6 years ago

Nevermind. Closing this issue. Was pushing the wrong string to creation. AdGroupPerformanceReportColumn should be AdGroupPerformanceReportRequest. Duh.