我正在尝试使用以下代码将密钥导入到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 ~>
您已经提供了
body='/tmp/apikey.csv
',但是import_api_keysAPI要求body是字节或可查找的文件,如object。您提供的文件名不正确。在相关问题 更多 >
编程相关推荐