BingAds / BingAds-PHP-SDK

Other
56 stars 45 forks source link

Request Type not being set properly by GoalsAndFunnelsReportRequest #50

Closed cashlion closed 6 years ago

cashlion commented 6 years ago

I've been attempting to pull Goal level conversion data for our Ad Accounts using the SDK but I am receiving an InternalServiceFault when submitting the report request. The SoapEnvelope body appears to be incorrect and I cannot figured why the SubmitGenerateReportRequest method is generating it incorrectly.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://bingads.microsoft.com/Reporting/v11" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body>
      <ns1:SubmitGenerateReportRequest>
         <ns1:ReportRequest>
            <Aggregation>Daily</Aggregation>
            <Columns>
               <xsd:string>TimePeriod</xsd:string>
               <xsd:string>Goal</xsd:string>
               <xsd:string>AccountId</xsd:string>
               <xsd:string>Conversions</xsd:string>
            </Columns>
            <Filter />
            <Scope>
               <AccountIds>
                  <xsd:string>XXXXXXX</xsd:string>
               </AccountIds>
               <AdGroups />
               <Campaigns />
            </Scope>
            <Time>
               <CustomDateRangeEnd>
                  <Day>24</Day>
                  <Month>1</Month>
                  <Year>2018</Year>
               </CustomDateRangeEnd>
               <CustomDateRangeStart>
                  <Day>18</Day>
                  <Month>1</Month>
                  <Year>2018</Year>
               </CustomDateRangeStart>
               <PredefinedTime />
            </Time>
            <ExcludeColumnHeaders />
            <ExcludeReportFooter />
            <ExcludeReportHeader />
            <Format>Csv</Format>
            <Language />
            <ReportName />
            <ReturnOnlyCompleteData>false</ReturnOnlyCompleteData>
         </ns1:ReportRequest>
      </ns1:SubmitGenerateReportRequest>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

As you can see, the ReportRequest type is not being set nor are the column types. When I dump the request that is generated by GoalsAndFunnelsReportRequest, it doesn't seem that the type is being set properly. For this type I get the following:

SoapVar {#1289
  +"enc_type": 301
  +"enc_value": Microsoft\BingAds\V11\Reporting\GoalsAndFunnelsReportRequest {#1236
    +Aggregation: "Daily"
    +Columns: array:4 [
      0 => "TimePeriod"
      1 => "Goal"
      2 => "AccountId"
      3 => "Conversions"
    ]
    +Filter: null
    +Scope: Microsoft\BingAds\V11\Reporting\AccountThroughAdGroupReportScope {#1274
      +AccountIds: array:30 [
        0 => "XXXXXX"
      ]
      +AdGroups: []
      +Campaigns: []
    }
    +Time: Microsoft\BingAds\V11\Reporting\ReportTime {#1275
      +CustomDateRangeEnd: Microsoft\BingAds\V11\Reporting\Date {#1279
        +Day: 24
        +Month: 1
        +Year: 2018
      }
      +CustomDateRangeStart: Microsoft\BingAds\V11\Reporting\Date {#1278
        +Day: 18
        +Month: 1
        +Year: 2018
      }
      +PredefinedTime: null
    }
    +ExcludeColumnHeaders: null
    +ExcludeReportFooter: null
    +ExcludeReportHeader: null
    +Format: "Csv"
    +Language: null
    +ReportName: null
    +ReturnOnlyCompleteData: false
  }
  +"enc_ns": "https://bingads.microsoft.com/Reporting/v11"
}

but, for example, CampaignReportRequest returns

SoapVar {#1258
  +"enc_type": 301
  +"enc_value": Microsoft\BingAds\V11\Reporting\CampaignPerformanceReportRequest {#1236
    +Aggregation: "Daily"
    +Columns: array:10 [
      0 => "TimePeriod"
      1 => "AccountId"
      2 => "CampaignId"
      3 => "CampaignName"
      4 => "Spend"
      5 => "Impressions"
      6 => "Clicks"
      7 => "Conversions"
      8 => "AveragePosition"
      9 => "Network"
    ]
    +Filter: null
    +Scope: Microsoft\BingAds\V11\Reporting\AccountThroughCampaignReportScope {#1240
      +AccountIds: array:1 [
        0 => "XXXXXXX"
      ]
      +Campaigns: null
    }
    +Time: Microsoft\BingAds\V11\Reporting\ReportTime {#1229
      +CustomDateRangeEnd: Microsoft\BingAds\V11\Reporting\Date {#1248
        +Day: 24
        +Month: 1
        +Year: 2018
      }
      +CustomDateRangeStart: Microsoft\BingAds\V11\Reporting\Date {#1247
        +Day: 18
        +Month: 1
        +Year: 2018
      }
      +PredefinedTime: null
    }
    +ExcludeColumnHeaders: null
    +ExcludeReportFooter: null
    +ExcludeReportHeader: null
    +Format: "Csv"
    +Language: null
    +ReportName: "Campaign Performance"
    +ReturnOnlyCompleteData: false
    +"MaxRows": 50000
  }
  +"enc_stype": "CampaignPerformanceReportRequest"
  +"enc_ns": "https://bingads.microsoft.com/Reporting/v11"
}

The enc_stype variable is not being set for GoalsAndFunnelsReportRequest and I believe that to be the issue. Any ideas on how I can get this resolved?