BingAds / BingAds-Python-SDK

Other
118 stars 164 forks source link

Report Request does not download result file #71

Closed CurtisGreenland closed 6 years ago

CurtisGreenland commented 6 years ago

I successfully started using the python SDK, using it to pull performance reports using the example code provided here on GitHub. I am using the report_request.py example. I had been using it daily since the beginning of December with no issues. However, on January 1, everything stopped working with no changes to the code, and I have not been successful since then.

It appears to get through the creation of the report request, but seems to fail on the submit and download,

The output from running the report_requests.py: runfile('Y:/report_requests.py', wdir='Y:/') Python loads the web service proxies at runtime, so you will observe a performance delay between program launch and main execution...

Awaiting Background Completion . . . Download result file: None

Awaiting Submit and Download . . . Download result file: None

Awaiting Download Results . . . Download result file: None Status: Success

Program execution completed

sflynn-mf commented 6 years ago

I am having the exact same issue I would love to see this resolved!

qingjuntian commented 6 years ago

Could you please provide more detail info? Do you have trackingID or requestID? Or account info?

eric-urban commented 6 years ago

@CurtisGreenland and @sflynn-mf are you running this in sandbox or production? If there is no data for the time period specified in the request, then by design the service return success without any download URL.

It would help to understand what report type, date range, report columns, etc you are requesting. You can turn on logging to capture the SOAP request and response. The trace will include TrackingId as @qingjuntian requested. Please don't share credentials or account IDs here in public view. If we need such details to continue the investigation then we will suggest that you contact support.

import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport.http').setLevel(logging.DEBUG)

BTW if you are indeed running the sample daily in production please note that only one of the "options" is needed. You can save time and resources commenting out or removing the other options e.g., just use Option A and remove B and C.

sflynn-mf commented 6 years ago

I am running in production as I am using OAuth to authenticate and I think I remember seeing somewhere sandbox mode wouldn't play nice with OAuth. You may be on to something with the date however give me a moment to check that out.

I did not change anything inside the file as far as date range, report columns, sort etc... The report type is set to what's returned by get_keyword_performance_report().

SOAP Messages:

Here is the request with time stamp 2018-01-15 16:24:44.351673.

<?xml version="1.0" encoding="UTF-8"?>

1c67ca0e-8846-4071-afb0-06e1e9f441a3 30000001087803661 Here is the response. 1be17748-56c6-46f9-a2df-676d93d91df9 Success What’s strange to me is that the status of THIS response is Success (the last two or three PollGenerateReportResponse's came back as pending) so that must mean the report has finished downloading, but the ReportDownloadUrl is always None when I check it in my program, and no files are ever downloaded to my machine. I just downloaded the SDK yesterday so my apologies if I'm missing something obvious!
sflynn-mf commented 6 years ago

Thank you so much @eric-urban. I changed the date range and it started working instantly.

Thank you so much for your time! I will consult occam's razor next time.

CurtisGreenland commented 6 years ago

@eric-urban I am in production. And there should be data for yesterday. If I run a keyword performance report in the Bing Ads UI, results come back.

Here is the output of the logging (I have X'd over all account ID's and developer token):

`<suds.sax.document.Document object at 0x000000000F62FA90> DEBUG:suds.client:headers = {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': b'"SubmitGenerateReport"', 'User-Agent': 'BingAdsSDKPython 11.5.7 (3, 6, 3)'} DEBUG:suds.transport.http:sending: URL: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc HEADERS: {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': b'"SubmitGenerateReport"', 'User-Agent': 'BingAdsSDKPython 11.5.7 (3, 6, 3)', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': b'"SubmitGenerateReport"', 'User-agent': 'BingAdsSDKPython 11.5.7 (3, 6, 3)'} MESSAGE: b'<?xml version="1.0" encoding="UTF-8"?>***</tns:AuthenticationToken>XXXXXXX</tns:CustomerAccountId>XXXXX</tns:CustomerId>XXXXXXXXXX</tns:DeveloperToken></SOAP-ENV:Header>Csv</ns1:Format>English</ns1:Language>My Keyword Performance Report</ns1:ReportName>false</ns1:ReturnOnlyCompleteData>Daily</ns1:Aggregation>TimePeriod</ns1:KeywordPerformanceReportColumn>AccountId</ns1:KeywordPerformanceReportColumn>CampaignId</ns1:KeywordPerformanceReportColumn>Keyword</ns1:KeywordPerformanceReportColumn>KeywordId</ns1:KeywordPerformanceReportColumn>DeviceType</ns1:KeywordPerformanceReportColumn>BidMatchType</ns1:KeywordPerformanceReportColumn>Clicks</ns1:KeywordPerformanceReportColumn>Impressions</ns1:KeywordPerformanceReportColumn>Ctr</ns1:KeywordPerformanceReportColumn>AverageCpc</ns1:KeywordPerformanceReportColumn>Spend</ns1:KeywordPerformanceReportColumn>QualityScore</ns1:KeywordPerformanceReportColumn></ns1:Columns>10</ns1:MaxRows>XXXXXXXX</ns2:long></ns1:AccountIds></ns1:Scope>Clicks</ns1:SortColumn>Ascending</ns1:SortOrder></ns1:KeywordPerformanceReportSort></ns1:Sort>Yesterday</ns1:PredefinedTime></ns1:Time></ns1:ReportRequest></ns1:SubmitGenerateReportRequest></ns0:Body></SOAP-ENV:Envelope>' DEBUG:suds.transport.http:received: CODE: HTTPStatus.OK HEADERS: Content-Type: text/xml; charset=utf-8 Server: Microsoft-IIS/8.5 X-Powered-By: ASP.NET Date: Tue, 16 Jan 2018 17:05:51 GMT Connection: close Content-Length: 399

MESSAGE: b'410bb168-7008-447e-8fe7-972fb457b833</h:TrackingId></s:Header>30000001231499722</s:Body></s:Envelope>' DEBUG:suds.client:HTTP succeeded: b'410bb168-7008-447e-8fe7-972fb457b833</h:TrackingId></s:Header>30000001231499722</s:Body></s:Envelope>' Awaiting Download Results . . . DEBUG:suds.client:sending to (https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc) message: <suds.sax.document.Document object at 0x000000000EC0DC18> DEBUG:suds.client:headers = {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': b'"PollGenerateReport"', 'User-Agent': 'BingAdsSDKPython 11.5.7 (3, 6, 3)'} DEBUG:suds.transport.http:sending: URL: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc HEADERS: {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': b'"PollGenerateReport"', 'User-Agent': 'BingAdsSDKPython 11.5.7 (3, 6, 3)', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': b'"PollGenerateReport"', 'User-agent': 'BingAdsSDKPython 11.5.7 (3, 6, 3)'} MESSAGE: b'<?xml version="1.0" encoding="UTF-8"?>***</tns:AuthenticationToken>XXXXXXX</tns:CustomerAccountId>XXXXXXXX</tns:CustomerId>XXXXXXXXXXXXX</tns:DeveloperToken></SOAP-ENV:Header>30000001231499722</ns1:ReportRequestId></ns1:PollGenerateReportRequest></ns0:Body></SOAP-ENV:Envelope>' DEBUG:suds.transport.http:received: CODE: HTTPStatus.OK HEADERS: Content-Type: text/xml; charset=utf-8 Server: Microsoft-IIS/8.5 X-Powered-By: ASP.NET Date: Tue, 16 Jan 2018 17:05:53 GMT Connection: close Content-Length: 495

MESSAGE: b'8710a3bd-71cf-437a-b198-ca14846431d5</h:TrackingId></s:Header>Success</s:Body></s:Envelope>' DEBUG:suds.client:HTTP succeeded: b'8710a3bd-71cf-437a-b198-ca14846431d5</h:TrackingId></s:Header>Success</s:Body></s:Envelope>' Download result file: None Status: Success

Program execution completed`

eric-urban commented 6 years ago

@CurtisGreenland we tracked down your request and found that one account has data for the date requested, whereas the other account does not. (Don't worry I will not share the account details in this public forum.) Keep in mind the sample is just a sample and picks one account to run against. Please double check that you are using the ID for the active account and you should get data returned.

CurtisGreenland commented 6 years ago

@eric-urban Thank you. With a little extra work, I have re-coded so that I can pull all accounts at the same time. And, indeed I have resolved. I appreciate your help.

gregroberts commented 6 years ago

I know this has been closed, but I'd just like to say how weird this behaviour is.

I just spent 25 minutes trying to debug why a ReportingDownloadOperation was saying it was ' successful, then the download not actually producing anything.

Looks like the only way to actually determine this has happened at run time is that download_result_file returns None.

eric-urban commented 6 years ago

@gregroberts thanks for the feedback! To help explain the reason for this change, previously clients had to download and parse the file only to discover in some cases there wasn't any data for the requested time period, scope, etc. Now the service returns nil ReportDownloadUrl to avoid the unnecessary download/parse steps.

amitlimbaskar commented 5 years ago

I have the same issue. When I hard code the account ID s for authorization_data.account _id field and comment following code : user=get_user_response=customer_service.GetUser( UserId=None ).User accounts=search_accounts_by_user_id(customer_service, user.Id)

then I get the result when I use first account account from sample code I get result as none. How to get auth_helper to identify all the active accounts and run the report for all of them ?

Shellbye commented 3 years ago

If there is no data for the time period specified in the request, then by design the service return success without any download URL

This is really not a good design.