BingAds GetAccount query multiple account ids

Shay Hayo 21 Reputation points
2020-10-05T20:58:25.04+00:00

Hey,

I'm using https://learn.microsoft.com/en-us/advertising/customer-management-service/getaccount?view=bingads-13 to get the account timezone, it's working for 1 account id but wanted to see if there is a way to query multiple accounts in one call?

Thanks

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.
382 questions
0 comments No comments
{count} votes

Accepted answer
  1. Eric Urban - MSFT 626 Reputation points Microsoft Employee
    2020-10-07T01:04:07.803+00:00

    @Shay Hayo here's an example SOAP request with the UserId predicate:

       xml  
       <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  
         <s:Header>  
           <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">SearchAccounts</Action>  
           <h:ApplicationToken i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="https://bingads.microsoft.com/Customer/v13" />  
           <h:AuthenticationToken xmlns:h="https://bingads.microsoft.com/Customer/v13">* * *</h:AuthenticationToken>  
           <h:DeveloperToken xmlns:h="https://bingads.microsoft.com/Customer/v13">* * *</h:DeveloperToken>  
           <h:Password i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="https://bingads.microsoft.com/Customer/v13" />  
           <h:UserName i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="https://bingads.microsoft.com/Customer/v13" />  
         </s:Header>  
         <s:Body>  
           <SearchAccountsRequest xmlns="https://bingads.microsoft.com/Customer/v13">  
             <Predicates xmlns:d4p1="https://bingads.microsoft.com/Customer/v13/Entities" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
               <d4p1:Predicate>  
                 <d4p1:Field>UserId</d4p1:Field>  
                 <d4p1:Operator>Equals</d4p1:Operator>  
                 <d4p1:Value>* * *</d4p1:Value>  
               </d4p1:Predicate>  
             </Predicates>  
             <Ordering xmlns:d4p1="https://bingads.microsoft.com/Customer/v13/Entities" i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />  
             <PageInfo xmlns:d4p1="https://bingads.microsoft.com/Customer/v13/Entities" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
               <d4p1:Index>0</d4p1:Index>  
               <d4p1:Size>100</d4p1:Size>  
             </PageInfo>  
           </SearchAccountsRequest>  
         </s:Body>  
       </s:Envelope>  
    

    To get the user ID, first call GetUser. For more details please see the get started guide i.e., step #5 here.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Shay Hayo 21 Reputation points
    2020-10-06T17:48:52.13+00:00

    Hey anonymous user-MSFT ,

    Tagging you since you helped me in the past, do you know if I can run the Get account on multiple account ids?
    any other way to get the timezone of multiple accounts?

    Thanks!

    0 comments No comments

  2. Eric Urban - MSFT 626 Reputation points Microsoft Employee
    2020-10-06T18:25:25.827+00:00

    @Shay Hayo I suggest please try SearchAccounts. This operation returns a list of AdvertiserAccount objects. I hope this helps!

    0 comments No comments

  3. Shay Hayo 21 Reputation points
    2020-10-06T20:22:43.113+00:00

    thanks anonymous user-MSFT ,

    Few questions:
    I tried to run this code, but I get empty result back
    Request:

    <s:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Header xmlns="https://bingads.microsoft.com/Customer/v13">
        <Action mustUnderstand="1">SearchAccounts</Action>
    <AuthenticationToken i:nil="false">valuehere</AuthenticationToken>
        <DeveloperToken i:nil="false">valuehere</DeveloperToken>
      </s:Header>
      <s:Body>
        <SearchAccountsRequest xmlns="https://bingads.microsoft.com/Customer/v13">
          <Predicates xmlns:e374="https://bingads.microsoft.com/Customer/v13/Entities" i:nil="false">
                <e374:Predicate>
              <e374:Field i:nil="false">AccountId</e374:Field>
              <e374:Operator>Equals</e374:Operator>
              <e374:Value i:nil="false">valuehere</e374:Value>
                   </e374:Predicate>
             </Predicates>
    
          <PageInfo xmlns:e376="https://bingads.microsoft.com/Customer/v13/Entities" i:nil="false">
               <e376:Index>1</e376:Index>
            <e376:Size>100</e376:Size>
          </PageInfo>
        </SearchAccountsRequest>
      </s:Body>
    </s:Envelope>
    

    Respond:
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId xmlns:h="https://bingads.microsoft.com/Customer/v13">11a41a54-8544-40b1-b346-b4979f5a5027</h:TrackingId></s:Header><s:Body><SearchAccountsResponse xmlns="https://bingads.microsoft.com/Customer/v13"><Accounts xmlns:a="https://bingads.microsoft.com/Customer/v13/Entities" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/></SearchAccountsResponse></s:Body></s:Envelope>

    can you guide me what is missing?

    1. how would you change the Predicates to query all accounts?

    thanks again

    0 comments No comments

  4. Shay Hayo 21 Reputation points
    2020-10-08T20:44:14.77+00:00

    thank you anonymous user-MSFT !!

    0 comments No comments