arambert / bing_ads_api

Ruby wrapper for the Microsoft Adcenter API
11 stars 17 forks source link

Bad reporting #1

Closed Dishwasha closed 8 years ago

Dishwasha commented 12 years ago

First off, thank you for this well timed gem. I am having an issue pulling reports from Bing Ads. I've attempted to use the report_utils as well as the ReportingService module without success.

api = BingAdsApi::Api.new({:authentication => {:method => 'ClientLogin', :developer_token => '##########', :password => '############', :user_name => '##############', :customer_id => '##########', :customer_account_id => '###########'}, :service => {:environment => 'PRODUCTION'}, :library => {:log_level => 'DEBUG'}})

service = api.service(:ReportingService, :v8)

When I attempt to do:

api.report_utils.download_report({:selector => {:fields => ['Date', 'Hour', 'Account Name', 'Campaign Name', 'Ad distribution', 'Quality Score', 'Impressions', 'Clicks', 'CTR', 'Average CPC', 'Spend', 'Avg. position']}, :report_name => 'Campaign Performance', :report_type => 'CampaignPerformanceReportRequest', :date_range_type => 'Hourly'})

This fails with "ArgumentError: Invalid URL: reportdownload/v8"

When I do (I've submitted with and without a block):

service.submit_generate_report({'CampaignPerformanceReportRequest' => {'ReportRequest' => {'Aggregation' => 'Hourly', 'Columns' => [], 'Filter' => nil, 'Scope' => nil, 'Time' => {'PredefinedTime' => 'Today'}}}})

This successfully does an HTTP Post, but the Bing API reports an internal error. The XML it is sending seems a little strange:

<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="https://adcenter.microsoft.com/v8" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><wsdl:DeveloperToken>#############</wsdl:DeveloperToken><wsdl:Password>#############</wsdl:Password><wsdl:UserName>############</wsdl:UserName><wsdl:CustomerId>#############</wsdl:CustomerId><wsdl:CustomerAccountId>###########</wsdl:CustomerAccountId></env:Header><env:Body><wsdl:SubmitGenerateReportRequest xmlns="https://adcenter.microsoft.com/v8"><wsdl:CampaignPerformanceReportRequest><wsdl:ReportRequest><wsdl:Aggregation>Hourly</wsdl:Aggregation><wsdl:Columns>Date</wsdl:Columns><wsdl:Columns>Hour</wsdl:Columns><wsdl:Columns>Account Name</wsdl:Columns><wsdl:Columns>Campaign Name</wsdl:Columns><wsdl:Columns>Ad distribution</wsdl:Columns><wsdl:Columns>Quality Score</wsdl:Columns><wsdl:Columns>Impressions</wsdl:Columns><wsdl:Columns>Clicks</wsdl:Columns><wsdl:Columns>CTR</wsdl:Columns><wsdl:Columns>Average CPC</wsdl:Columns><wsdl:Columns>Spend</wsdl:Columns><wsdl:Columns>Avg. position</wsdl:Columns><wsdl:Filter xsi:nil="true"/><wsdl:Scope xsi:nil="true"/><wsdl:Time><wsdl:PredefinedTime>Today</wsdl:PredefinedTime></wsdl:Time></wsdl:ReportRequest></wsdl:CampaignPerformanceReportRequest></wsdl:SubmitGenerateReportRequest></env:Body></env:Envelope>

As you can see, it namespaces everything to wsdl which doesn't seem right. Any assistance or guidance on how to use this gem to pull reports would be much appreciated. Thank you for your time.

bessey commented 11 years ago

I have the exact same problem so if you managed to resolve this please let me know!

arambert commented 8 years ago

Is this still an issue with the code in the master branch ? If not I will close this issue.