Boto3缺少必需的列“Key”错误,即使在

2024-05-16 10:29:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用以下代码将密钥导入到API网关

import boto3, hashlib, random, csv

apigateway = boto3.client('apigateway')

apikey = 'test'

with open('/tmp/apikey.csv', 'wb') as csvfile:
    filewriter = csv.writer(csvfile, delimiter=',',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
    filewriter.writerow(['Name', 'Key', 'Enabled', 'usageplanIds'])
    filewriter.writerow(['testkey', apikey, 'TRUE', '963uwo'])

response = apigateway.import_api_keys(
    body='/tmp/apikey.csv',
    format='csv',
    failOnWarnings=False
)

但是这给了我

^{pr2}$

我也尝试过直接复制http://docs.aws.amazon.com/apigateway/latest/developerguide/api-key-file-format.html中给出的示例,但是仍然得到相同的错误,即使Key已经明确设置。在

这是我的/tmp/apikey.csv在

jonathan@ubuntu ~> cat /tmp/apikey.csv
Name,Key,Enabled,usageplanIds
testkey,test,TRUE,963uwo
jonathan@ubuntu ~>

Tags: csvcsvfilekeynametestimportenabledboto3