调用AWS CLI的SendApiAsset时遇NotFoundException错误的解决求助
解决AWS Data Exchange调用SimilarWeb API的NotFoundException错误
问题根源
错误信息An error occurred (NotFoundException) when calling the SendApiAsset operation: No method found matching route / for http method GET明确指向:你指定的空路径--path ''并非SimilarWeb API资产支持的有效端点,该API没有根路径的GET请求处理逻辑。
修复方案
1. 确认SimilarWeb API的有效端点
- 登录AWS Data Exchange控制台,找到已订阅的SimilarWeb数据集
- 进入对应API资产的详情页,查看API文档或使用指南,获取所有可用的路径(例如
/website/rank、/traffic/overview)、支持的HTTP方法及参数要求
2. 修正CLI命令
将空路径替换为实际有效的API路径,并调整查询参数为对应端点要求的内容,示例命令如下:
aws dataexchange send-api-asset \ --data-set-id **************************** \ --revision-id **************************** \ --asset-id ******************************* \ --method GET \ --path '/website/rank' \ --query-string-parameters 'domain=example.com,country=US' \ --output json | jq -r '.Body'
3. boto3调用示例
如果使用Python的boto3库,可参考以下代码:
import boto3 import json # 初始化Data Exchange客户端 data_exchange = boto3.client('dataexchange') # 调用指定API端点 response = data_exchange.send_api_asset( DataSetId='****************************', RevisionId='****************************', AssetId='*******************************', Method='GET', Path='/website/rank', QueryStringParameters='domain=example.com,country=US' ) # 解析并打印结果 api_response = json.loads(response['Body']) print(api_response)
4. 额外检查项
- 确认
data-set-id、revision-id、asset-id完全正确,无字符遗漏或错误 - 严格按照SimilarWeb API文档要求传递查询参数,部分参数有特定格式(如国家代码需为ISO 3166-1 alpha-2格式)
- 确保你的AWS IAM账号拥有
dataexchange:SendApiAsset操作权限
内容的提问来源于stack exchange,提问作者Mustapha Unubi Momoh
相关产品推荐
相关产品推荐

