调用Bing Ads API GetLabelAssociationsByEntityIds遇UserIsNotAuthorized 106错误
解决Bing Ads API获取标签关联时的"用户未代表授权开发者"错误
当调用Bing Ads v13 API的GetLabelAssociationsByEntityIds接口通过Campaign ID获取关联标签时,返回错误:用户未代表授权开发者。
请求信息
请求地址:https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc
请求SOAP XML:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/CampaignManagement/v13" xmlns:ns0="https://bingads.microsoft.com/CampaignManagement/v13" xmlns:ns1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header> <tns:AuthenticationToken> TOKEN </tns:AuthenticationToken> <tns:CustomerAccountId>ACCOUNT_ID</tns:CustomerAccountId> <tns:CustomerId>PATENT_ID</tns:CustomerId> <tns:DeveloperToken>DEVELOPER_TOKEN</tns:DeveloperToken> </SOAP-ENV:Header> <ns2:Body> <ns0:GetLabelAssociationsByEntityIdsRequest> <ns0:EntityIds> <ns1:long>CAMPAIGN_ID</ns1:long> <ns1:long>CAMPAIGN_ID</ns1:long> <ns1:long>CAMPAIGN_ID</ns1:long> <ns1:long>CAMPAIGN_ID</ns1:long> <ns1:long>CAMPAIGN_ID</ns1:long> <ns1:long>CAMPAIGN_ID</ns1:long> </ns0:EntityIds> <ns0:EntityType>Campaign</ns0:EntityType> </ns0:GetLabelAssociationsByEntityIdsRequest> </ns2:Body> </SOAP-ENV:Envelope>
Python调用代码
使用bingads.v13库的调用代码:
campaign_service = ServiceClient(service='CampaignManagementService', version=13, authorization_data=authorization_data, environment='production') get_label_associations_by_entity_ids = campaign_service.GetLabelAssociationsByEntityIds( EntityIds={'long': get_entity_ids}, EntityType='Campaign' )
错误响应内容
返回的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: 3511ac9a-a751-4c0d-9b51-1ed04540a225.</faultstring> <detail> <ApiFaultDetail xmlns="https://bingads.microsoft.com/CampaignManagement/v13" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <TrackingId xmlns="https://adapi.microsoft.com">3511ac9a-a751-4c0d-9b51-1ed04540a225</TrackingId> <BatchErrors /> <OperationErrors> <OperationError><Code>106</Code> <Details i:nil="true" /> <ErrorCode>UserIsNotAuthorized</ErrorCode> <Message>The user does not represent a authorized developer.</Message> </OperationError> </OperationErrors> </ApiFaultDetail> </detail> </s:Fault> </s:Body> </SOAP-ENV:Envelope>
问题排查与解决
该错误(错误码106,UserIsNotAuthorized)的常见原因及解决方法:
- 开发者令牌问题:确认
DeveloperToken是Bing Ads开发者中心注册的有效令牌,且已关联目标客户账户。 - 授权令牌权限不足:检查
AuthenticationToken对应的用户是否拥有目标账户的访问权限,需是账户的授权开发者或具备操作权限。 - 账户ID不匹配:验证
CustomerAccountId和CustomerId是否与授权令牌对应的账户信息一致。 - 环境不匹配:确保
environment参数(生产/沙箱)与令牌所属环境一致,沙箱令牌无法在生产环境使用,反之亦然。
内容的提问来源于stack exchange,提问作者adam_jura-czarnecki
相关产品推荐
相关产品推荐

