这个错误消息通常表示您在请求Sponsored Brands报告时使用了无效的报告类型ID。下面是一个示例代码,展示如何创建Sponsored Brands报告并避免此错误:
import boto3
def create_sponsored_brands_report(client):
response = client.create_report_definition(
ReportName='MySponsoredBrandsReport',
ReportType='SponsoredBrands',
ReportOptions={
'CampaignId': '12345678', # 替换为有效的广告系列ID
'Segment': 'keyword',
'ReportDate': {
'StartDate': '2022-01-01',
'EndDate': '2022-01-31'
}
}
)
return response['ReportId']
def main():
client = boto3.client('marketplacecommerceanalytics', region_name='us-east-1') # 替换为所需的AWS区域
try:
report_id = create_sponsored_brands_report(client)
print(f"Created Sponsored Brands report with ID: {report_id}")
except Exception as e:
print(f"Failed to create Sponsored Brands report: {str(e)}")
if __name__ == '__main__':
main()
在上面的示例中,我们使用boto3库创建了一个名为MySponsoredBrandsReport的Sponsored Brands报告。请确保将CampaignId替换为有效的广告系列ID,并根据需要调整ReportDate和其他报告选项。
如果您仍然遇到相同的错误消息,请确保您提供的广告系列ID是有效的,并且您具有足够的权限来创建报告。另外,请检查您是否在请求中正确指定了报告类型为"SponsoredBrands"。