I'm using the BingAds Python API to access an account with several clients under it. After retrieving the accounts from CustomerService.SearchAccounts(), I pass the Account.Id field to a BulkService client:
accounts = basic.search_accounts_by_user_id(customer_service, user.Id)
bulk_service = ServiceClient(
service='BulkService',
version=13,
authorization_data=authorization_data,
environment=ENVIRONMENT
)
download_entities = bulk_service.factory.create('ArrayOfDownloadEntity')
download_entities.DownloadEntity = ['Campaigns','AdGroups']
for account in accounts['AdvertiserAccount']:
#print(account)
response = bulk_service.DownloadCampaignsByAccountIds(
AccountIds={'long':[account.Id]},
DataScope=['EntityData'],
#DownloadFileType=FILE_TYPE,
DownloadEntities=download_entities,
FormatVersion="6.0"
)
This throws the following error:
Traceback (most recent call last):
File "main.py", line 144, in <module>
main(authorization_data)
File "main.py", line 73, in main
FormatVersion="6.0"
File "C:\Users\Bob\Anaconda3\envs\waterbear\lib\site-packages\bingads\service_client.py", line 273, in __call__
raise ex
File "C:\Users\Bob\Anaconda3\envs\waterbear\lib\site-packages\bingads\service_client.py", line 265, in __call__
response = self.service_client.soap_client.service.__getattr__(self.name)(*args, **kwargs)
File "C:\Users\Bob\Anaconda3\envs\waterbear\lib\site-packages\suds\client.py", line 521, in __call__
return client.invoke(args, kwargs)
File "C:\Users\Bob\Anaconda3\envs\waterbear\lib\site-packages\suds\client.py", line 581, in invoke
result = self.send(soapenv)
File "C:\Users\Bob\Anaconda3\envs\waterbear\lib\site-packages\suds\client.py", line 619, in send
description=tostr(e), original_soapenv=original_soapenv)
File "C:\Users\Bob\Anaconda3\envs\waterbear\lib\site-packages\suds\client.py", line 670, in process_reply
raise WebFault(fault, replyroot)
suds.WebFault: Server raised fault: 'Invalid client data. Check the SOAP fault details for more information. TrackingId: xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx.'
Is this the wrong ID to pass to the BulkService?
OR: I can use the BulkServiceManager on the whole account, but it appears to return 5-10 rows for a random client each time; not the full data, and I can't find a way to pass it a client ID so I could iterate. If anyone has a simpler solution using BulkServiceManager, I'm open to that, too.
EDIT: Actual SOAP response during failure:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Server</faultcode>
<faultstring xml:lang="en-US">Invalid client data. Check the SOAP fault details for more information. TrackingId: 5e8cbcb6-2d29-49e9-83e3-b91d94c712b7.</faultstring>
<detail>
<AdApiFaultDetail xmlns="https://adapi.microsoft.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<TrackingId>xxxxxxxxxxx</TrackingId>
<Errors>
<AdApiError>
<Code>105</Code>
<Detail i:nil="true" />
<ErrorCode>InvalidCredentials</ErrorCode>
<Message>Authentication failed. Either supplied credentials are invalid or the account is inactive</Message>
</AdApiError>
</Errors>
</AdApiFaultDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>