I've been able to get this far without knowing about XML since the Savon gem translates Ruby code into XML, but now I'm stuck. I'm requesting a CampaignPerformanceReport from the API and I'm able to successfully retrieve the data I need, but now I need to add a filter to only get 'Paused' campaigns.
Following this documentation I sent this message to the API:
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v13" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://bingads.microsoft.com/Reporting/v13">
<env:Header>
<AuthenticationToken>foo</AuthenticationToken>
<CustomerAccountId>foo</CustomerAccountId>
<CustomerId>foo</CustomerId>
<DeveloperToken>foo</DeveloperToken>
</env:Header>
<env:Body>
<tns:SubmitGenerateReportRequest>
<ReportRequest xsi:nil="false" xsi:type="CampaignPerformanceReportRequest">
<ExcludeColumnHeaders>true</ExcludeColumnHeaders>
<ExcludeReportFooter>true</ExcludeReportFooter>
<ExcludeReportHeader>true</ExcludeReportHeader>
<Format>Csv</Format>
<Language>English</Language>
<ReportName>CampaignPerformanceReportRequest</ReportName>
<ReturnOnlyCompleteData>false</ReturnOnlyCompleteData>
<Aggregation>Summary</Aggregation>
<Columns>
<CampaignPerformanceReportColumn>CampaignName</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>CampaignStatus</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Spend</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Impressions</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Clicks</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Conversions</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Revenue</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>PhoneCalls</CampaignPerformanceReportColumn>
</Columns>
<Filter>
<CampaignStatusReportFilter>Paused</CampaignStatusReportFilter>
</Filter>
<Scope>
<AccountIds xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a1:long>foo</a1:long>
</AccountIds>
</Scope>
<Time>
<CustomDateRangeEnd>
<Day>31</Day>
<Month>01</Month>
<Year>2019</Year>
</CustomDateRangeEnd>
<CustomDateRangeStart>
<Day>01</Day>
<Month>01</Month>
<Year>2019</Year>
</CustomDateRangeStart>
<PredefinedTime xsi:nil="true"/>
<ReportTimeZone>EasternTimeUSCanada</ReportTimeZone>
</Time>
</ReportRequest>
</tns:SubmitGenerateReportRequest>
</env:Body>
</env:Envelope>
The request is accepted and processed, but the data that is returned shows only 'Active' campaigns. I'm sure there is an issue with the way I'm filtering. Here is the Ruby code I'm using to generate the request.
report_request = {
'@xsi:nil' => false,
'@xsi:type' => 'CampaignPerformanceReportRequest',
'ExcludeColumnHeaders' => true,
'ExcludeReportFooter' => true,
'ExcludeReportHeader' => true,
'Format' => 'Csv',
'Language' => 'English',
'ReportName' => 'CampaignPerformanceReportRequest',
'ReturnOnlyCompleteData' => false,
'Aggregation' => 'Summary',
'Columns' => {
'CampaignPerformanceReportColumn' => [
'CampaignName',
'CampaignStatus',
'Spend',
'Impressions',
'Clicks',
'Conversions',
'Revenue',
'PhoneCalls'
]
},
'Filter' => { 'CampaignStatusReportFilter' => 'Paused' },
'Scope' => {
'AccountIds' => {
'@xmlns:a1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays',
'a1:long' => account_id,
}
},
etc...
}
I've tried matching the syntax in the documentation linked to above exactly, but it still returns only 'Active' campaigns, which leads me to believe that that is the default setting and the API just ignores my improper filtering.
If anyone could help me figure out what I'm doing wrong here it would be greatly appreciated.