Reputation: 11375
I'm trying to import a key to API gateway with the following code
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
)
However that gives me
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'
I've also tried copying directly the examples given at http://docs.aws.amazon.com/apigateway/latest/developerguide/api-key-file-format.html but still get the same error, even though Key is clearly set.
Here's my /tmp/apikey.csv
jonathan@ubuntu ~> cat /tmp/apikey.csv
Name,Key,Enabled,usageplanIds
testkey,test,TRUE,963uwo
jonathan@ubuntu ~>
Upvotes: 0
Views: 573
Reputation: 78842
You have supplied body='/tmp/apikey.csv
' but the import_api_keys API expects body to be bytes or a seekable file-like object. You have incorrectly supplied a filename.
Upvotes: 4