0
我試圖導入一個關鍵API網關用下面的代碼Boto3缺少必需的列「重點」,即使設定錯誤
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
)
然而,讓我
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 312, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 601, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the ImportApiKeys operation: Missing required column 'Key'
我已經也試過直接複製在http://docs.aws.amazon.com/apigateway/latest/developerguide/api-key-file-format.html給出的例子,但仍然得到同樣的錯誤,即使鑰匙明確規定。
這裏是我的/tmp/apikey.csv
[email protected] ~> cat /tmp/apikey.csv
Name,Key,Enabled,usageplanIds
testkey,test,TRUE,963uwo
[email protected] ~>
除了事實,你不寫二進制線和我的翻譯不喜歡'模式=「wb'',你可以試試'的FileWriter = csv.writer(csvfile,分隔符=」「 lineterminator =」 \ n「)'? – Uvar
沒有工作,我已經更新的問題,包括csv文件 – Jonathan