bingads V13 report request fails in python sdk

721 Views Asked by At

I try to download a bingads report using python SDK, but I keep getting an error says: "Type not found: 'Aggregation'" after submitting a report request. I've tried all 4 options mentioned in the following link: https://github.com/BingAds/BingAds-Python-SDK/blob/master/examples/v13/report_requests.py

Authentication process prior to request works just fine.

I execute the following:

     report_request = get_report_request(authorization_data.account_id)


        reporting_download_parameters = ReportingDownloadParameters(
            report_request=report_request,
            result_file_directory=FILE_DIRECTORY,
            result_file_name=RESULT_FILE_NAME,
            overwrite_result_file=True,  # Set this value true if you want to overwrite the same file.
            timeout_in_milliseconds=TIMEOUT_IN_MILLISECONDS

            
        )
        output_status_message("-----\nAwaiting download_report...")

        download_report(reporting_download_parameters)
 

after a careful debugging, it seems that the program fails when trying to execute a command within "reporting_service_manager.py". Here is workflow:

download_report(self, download_parameters):
    report_file_path = self.download_file(download_parameters)

then:

download_file(self, download_parameters):
       operation = self.submit_download(download_parameters.report_request)

then:

submit_download(self, report_request):
        self.normalize_request(report_request)
        response = self.service_client.SubmitGenerateReport(report_request)

SubmitGenerateReport starts a sequence of events ending with a call to "_SeviceCall.init" function within "service_client.py", returning an exception "Type not found: 'Aggregation'"

 try:
                response = self.service_client.soap_client.service.__getattr__(self.name)(*args, **kwargs)
                return response
            except Exception as ex:
                if need_to_refresh_token is False \
                        and self.service_client.refresh_oauth_tokens_automatically \
                        and self.service_client._is_expired_token_exception(ex):
                    need_to_refresh_token = True
                else:
                    raise ex

Can anyone shed some light? .

Thanks

2

There are 2 best solutions below

0
On

This may be a bit late 2 months after the fact but maybe this will help someone else. I had the same error (though I suppose it may not be the same issue). It does look like you did what I did (and I'm sure others will as well): copy-paste the Microsoft example code and tried to run it only to find that it didn't work.

I spent quite some time trying to debug the issue and it looked to me like the XML wasn't being searched correctly. I was using suds-py3 for the script at the time so I tried suds-community and everything just worked after that.

I also re-read the Bing Ads API walkthrough for getting started again and found that they recommend suds-jurko instead.

Long story short: If you want to use the bingads API don't use suds-py3, use either suds-community (which I can confirm works for everything I've used the API for) or suds-jurko (which is the one recommended by Microsoft).

1
On

Please be sure to set Aggregation e.g., as shown here.

aggregation = 'Daily'

If the report type does not use aggregation, you can set Aggregation=None.

Does this help?