question

ShayHayo-9764 avatar image
0 Votes"
ShayHayo-9764 asked ShayHayo-9764 answered

BingAds GetAccount query multiple account ids

Hey,

I'm using https://docs.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

advertising-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

EricUrban-MSFT avatar image
0 Votes"
EricUrban-MSFT answered

@ShayHayo-9764 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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ShayHayo-9764 avatar image
0 Votes"
ShayHayo-9764 answered

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!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

EricUrban-MSFT avatar image
0 Votes"
EricUrban-MSFT answered

@ShayHayo-9764 I suggest please try SearchAccounts. This operation returns a list of AdvertiserAccount objects. I hope this helps!


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ShayHayo-9764 avatar image
0 Votes"
ShayHayo-9764 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ShayHayo-9764 avatar image
0 Votes"
ShayHayo-9764 answered

thank you anonymous user-MSFT !!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.