'AWS Lambda export Api Gatewat backup to S3

I am trying to configure an lambda function which will export Api backup to S3. But when i try to get an ordinary swagger backup through lambda using this script-

import boto3
client = boto3.client('apigateway')
def lambda_handler(event, context):
    response = client.get_export(
        restApiId='xtmeuujbycids',
        stageName='test',
        exportType='swagger',
        parameters={
            extensions: 'authorizers'
        },
        accepts='application/json'
        )

I am getting this error- [ERROR] NameError: name 'extensions' is not defined

Please help to resolve this issues.



Solution 1:[1]

Could you please check if the documentation has been explicitly published, and if it has been deployed to a stage before it available in the export.

Solution 2:[2]

The problem is in:

parameters={
    extensions: 'authorizers'
        }

You're passing a dictionary, which is ok, but the key should be a string. Since you don't have quotes around extensions, Python is trying to resolve it as a variable with the name extensions which doesn't exist in your code, and so it gives the NameError

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vaquar khan
Solution 2 Caldazar