我正在使用 BingAds Python API 访问一个包含多个客户端的帐户。从 CustomerService.SearchAccounts() 检索帐户后,我将 Account.Id 字段传递给 BulkService 客户端:
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"
)
这会引发以下错误:
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.'
这是传递给 BulkService 的错误 ID 吗?
或者:我可以在整个帐户上使用 BulkServiceManager,但它似乎每次为随机客户端返回 5-10 行;不是完整的数据,我找不到将客户端 ID 传递给它的方法,因此我可以进行迭代。如果有人使用 BulkServiceManager 有更简单的解决方案,我也愿意接受。
编辑:失败期间的实际 SOAP 响应:
<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>