[SearchAccounts] Error 3030 Predicate passed in search is invalid

Lonny Kapelushnik 16 Reputation points
2021-03-03T15:32:35.54+00:00

I am using the PHP SDK (https://github.com/BingAds/BingAds-PHP-SDK) to get data from our Ads and am running into an issue. I originally posted this as a GH issue (https://github.com/BingAds/BingAds-PHP-SDK/issues/145), but I think here may be more appropriate.

When calling SearchAccounts I am receiving "Predicate passed in search is invalid" regardless of which predicate is passed in. I copied the code and modified from your samples. I don't believe I've done anything wrong.

I can confirm that the OAuthToken is valid and that when it expires I'm able to use the same OAuthWebAuthCodeGrant and AuthorizationData to generate new tokens from the refresh token.

Here is a sample of the PHP code (I adapted this code from https://github.com/BingAds/BingAds-PHP-SDK/blob/main/samples/V13/AuthHelper.php#L145-L166):

$authentication = (new OAuthWebAuthCodeGrant())
  ->withEnvironment(ApiEnvironment::Production)
  ->withClientId($clientId)
  ->withClientSecret($clientSecret);

$this->authorizationData = (new AuthorizationData())
  ->withAuthentication($authentication)
  ->withDeveloperToken($developerToken);

$this->authorizationData->Authentication->withOAuthTokens($oAuthTokens);

$page = 0;
$limit = 1000;
$proxy = new ServiceClient(
    ServiceClientType::CustomerManagementVersion13,
    $this->authorizationData,
    ApiEnvironment::Production
);

$pageInfo = new Paging();
$pageInfo->Index = $page;
$pageInfo->Size = $limit;

$predicate = new Predicate();
$predicate->Field = 'AccountLifeCycleStatus';
$predicate->Operator = PredicateOperator::Equals;
$predicate->Value = 'Active';

$request = new SearchAccountsRequest();
$request->Ordering = null;
$request->PageInfo = $pageInfo;
$request->Predicates = [$predicate];

$proxy->GetService()->SearchAccounts($request);

Here is the XML generated from calling $proxy->GetService()->__getLastRequest():

<?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/Customer/v13/Entities" xmlns:ns2="https://bingads.microsoft.com/Customer/v13" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Header>
    <ns2:CustomerAccountId/><ns2:CustomerId/>
    <ns2:DeveloperToken>*snip*</ns2:DeveloperToken>
    <ns2:UserName/>
    <ns2:Password/>
    <ns2:AuthenticationToken>*snip*</ns2:AuthenticationToken>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns2:SearchAccountsRequest>
      <ns2:Predicates>
        <ns1:Predicate>
          <ns1:Field>AccountLifeCycleStatus</ns1:Field>
          <ns1:Operator>Equals</ns1:Operator>
          <ns1:Value>Active</ns1:Value>
        </ns1:Predicate>
      </ns2:Predicates>
      <ns2:Ordering xsi:nil="true"/>
      <ns2:PageInfo>
        <ns1:Index>0</ns1:Index>
        <ns1:Size>1000</ns1:Size>
      </ns2:PageInfo>
    </ns2:SearchAccountsRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And here is the response I receive:

{"ApiFault":{"TrackingId":"51977592-dc41-471b-83d9-5eded4974e17","OperationErrors":{"OperationError":{"Code":"3030","Details":"","Message":"Predicate passed in search is invalid."}}}}
Microsoft Advertising API
Microsoft Advertising API
A Microsoft API that provides programmatic access to Microsoft Advertising to manage large campaigns or to integrate your marketing with other in-house systems.
399 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Eric Urban - MSFT 626 Reputation points Microsoft Employee
    2021-03-07T01:26:12.297+00:00

    @Lonny Kapelushnik - Per documentation:

    If the predicate Field is set to "AccountLifeCycleStatus", then you must specify one additional predicate with the Field set to another value such as UserId.

    Please let me know if this resolves the issue or if you have any follow up questions.