2

We are facing a problem with Bing Ads API version 9 and 10.

We are using the ConstructWithAccountAndCustomerId() method of the ClientProxy class, providing a valid DeveloperToken, AccountId, and AuthenticationToken (OAuth), like so:

$proxy = ClientProxy::ConstructWithAccountAndCustomerId($wsdl, null, null, $DeveloperToken, $AccountId, null, $AuthenticationToken);

Our goal is to retrieve and list all campaigns for an account. However, when running:

print_r($proxy->GetService()->GetCampaignsByAccountId($AccountId));

...we are faced with this error:

[Code] => 1102 
[Details] => AccountId is invalid 
[ErrorCode] => CampaignServiceInvalidAccountId 
[Message] => The account ID is invalid.

Now we've double and triple checked that the AccountID is right (https://msdn.microsoft.com/en-US/library/bing-ads-getting-started.aspx#accountcustomerid).

We've also tried this with both Bing Ads API v9, and Bing Ads API v10 - as well as the Bing Ads SDK Api by CPCStrategy - no dice anywhere.

Any ideas on what we are missing?

Thanks

camursm
  • 63
  • 1
  • 8

1 Answers1

0

The problem and solution was ridiculously straightforward: the GetCampaignsByAccountId service operation requires a special request object, the Account ID in itself is not enough:

$request = new GetCampaignsByAccountIdRequest(); 
$request->AccountId = $AccountId; 
$request->CampaignType = CampaignType::SearchAndContent; 

With this object defined and then feed to the GetCampaignsByAccountId service operation, all campaigns of the account are successfully returned:

print_r($proxy->GetService()->GetCampaignsByAccountId($request));
camursm
  • 63
  • 1
  • 8