BingAds / BingAds-PHP-SDK

Other
56 stars 46 forks source link

Need help. SubmitGenerateReport always throw error: The request message is null. #182

Closed jasonbigl closed 1 year ago

jasonbigl commented 1 year ago

Hi,

I would like to ask why my SubmitGenerateReport always failed, can't find any information on the documents...

       //request object
        $apiRequest = new CampaignPerformanceReportRequest();

        $apiRequest->Aggregation = ReportAggregation::Daily;
        $apiRequest->Columns = [
            CampaignPerformanceReportColumn::TimePeriod,
            CampaignPerformanceReportColumn::Spend,
        ];

        //time
        $time = new ReportTime();
        $startDateObj = new Date();
        $startDateObj->Year = 2023;
        $startDateObj->Month = 3;
        $startDateObj->Day = 21;
        $time->CustomDateRangeStart = $startDateObj;

        $endDateObj = new Date();
        $endDateObj->Year = 2023;
        $endDateObj->Month = 3;
        $endDateObj->Day = 22;
        $time->CustomDateRangeEnd = $endDateObj;
        $apiRequest->Time = $time;

        //filter
        $filter = new CampaignPerformanceReportFilter();
        $filter->AccountStatus = AccountStatusReportFilter::Active;
        $apiRequest->Filter = $filter;

        //scope
        $scope = new AccountThroughCampaignReportScope();
        $scope->AccountIds = [xxxx];
        $campaignReportScope = new CampaignReportScope();
        $campaignReportScope->AccountId = xxxx;
        $campaignReportScope->CampaignId = xxxx;
        $scope->Campaigns = [$campaignReportScope];
        $apiRequest->Scope = $scope;

        $data = $client->GetService()->SubmitGenerateReport($apiRequest);

can you tell me where am I wrong? I really appreciate any help.

jasonbigl commented 1 year ago

for anyone who may encounter this problem, you need to use SoapVar to encode the report, check example code: https://github.com/BingAds/BingAds-PHP-SDK/blob/main/samples/V13/ReportRequests.php#L282

Solved.