Issue with Passing Query String Parameters to AWS API Gateway and Lambda Function

I’m having trouble passing query string parameters to my AWS API Gateway and getting them processed correctly by my Lambda function. Despite following several tutorials and guides, my Lambda function consistently returns an error indicating that the official_name parameter is missing.

Thank you in advance, newbie trying to learn Serverless AWS and I am stuck.

Website>API Gateway>Lambda>DynamoDB

Setup Details:

API Gateway:

I have set up a GET method in API Gateway.
Under Method Request, I’ve added a query string parameter official_name and marked it as required.
Under Integration Request, I have configured a mapping template for application/json as follows:

{
    "official_name": "$input.params('official_name')"
}

enter image description here
The API is deployed to a stage named deploy.

Lambda Function:

My Lambda function is designed to handle the incoming request and return HTML content based on the official_name parameter.

import json
import boto3

def lambda_handler(event, context):
    dynamodb = boto3.client('dynamodb')
    s3 = boto3.client('s3')
    
    # Check if 'queryStringParameters' exists and is not None
    query_params = event.get('queryStringParameters', {})
    
    # Get 'official_name' from query string parameters
    official_name = query_params.get('official_name', '')
    
    if not official_name:
        return {
            'statusCode': 400,
            'body': json.dumps({'error': 'official_name parameter is required'}),
            'headers': {
                'Content-Type': 'application/json',
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Methods': 'GET,OPTIONS',
                'Access-Control-Allow-Headers': 'Content-Type, x-api-key'
            }
        }
    
    print(f"Official Name from request: {official_name}")
    
    try:
        response = dynamodb.get_item(
            TableName='GlobalSkiAtlasDatabase',
            Key={
                'OfficalName': {'S': official_name}
            }
        )
        
        print(f"DynamoDB Response: {response}")
        
        if 'Item' in response:
            item = response['Item']
            
            formatted_item = {k: list(v.values())[0] for k, v in item.items()}
            
            print(f"Formatted Item: {formatted_item}")
            
            skiable_acres = formatted_item.get('Skiable Acres', 'N/A')
            print(f"Skiable Acres: {skiable_acres}")
            
            s3_bucket = 'globalskiatlas.com'
            s3_key = 'skiresort.html'
            
            try:
                s3_response = s3.get_object(Bucket=s3_bucket, Key=s3_key)
                html_template = s3_response['Body'].read().decode('utf-8')
            except Exception as e:
                print(f"Error fetching HTML template from S3: {str(e)}")
                return {
                    'statusCode': 500,
                    'body': json.dumps({'error': str(e)}),
                    'headers': {
                        'Content-Type': 'application/json',
                        'Access-Control-Allow-Origin': '*',
                        'Access-Control-Allow-Methods': 'GET,OPTIONS',
                        'Access-Control-Allow-Headers': 'Content-Type, x-api-key'
                    }
                }
            
            html_content = html_template.format(
                resort_name=formatted_item.get('Name', 'N/A'),
                owner=formatted_item.get('Owner', 'N/A'),
                ticket_price_youth=formatted_item.get('Ticket Price Youth', 'N/A'),
                ticket_price_adult=formatted_item.get('Ticket Price Adult', 'N/A'),
                ticket_price_senior=formatted_item.get('Ticket Price Senior', 'N/A'),
                rental_price=formatted_item.get('Rental', 'N/A'),
                multi_mountain_passes=formatted_item.get('Multi-Mountain Pass', 'N/A'),
                major_cities=formatted_item.get('Major Cities', 'N/A'),
                vertical_drop=formatted_item.get('Vertical Drop', 'N/A'),
                base_altitude=formatted_item.get('Base Altitude', 'N/A'),
                peak_altitude=formatted_item.get('Peak Altitude', 'N/A'),
                trails=formatted_item.get('Trails Total', 'N/A'),
                lifts=formatted_item.get('Lifts', 'N/A'),
                skiable_acres=skiable_acres,
                longest_run=formatted_item.get('Longest Run', 'N/A'),
                snow_making=formatted_item.get('Snow Making', 'N/A'),
                annual_snowfall=formatted_item.get('Annual Snowfall', 'N/A'),
                operating_hours_weekdays=formatted_item.get('Operating Hours: Weekdays', 'N/A'),
                operating_hours_weekends=formatted_item.get('Operating Hours: Weekends', 'N/A'),
                opening_date=formatted_item.get('Opening Date', 'N/A'),
                closing_date=formatted_item.get('Closing Date', 'N/A'),
                days_open=formatted_item.get('Days Open', 'N/A'),
                resort_lodging=formatted_item.get('Resort Lodging', 'N/A'),
                night_skiing=formatted_item.get('Night Skiing', 'N/A'),
                terrain_park=formatted_item.get('Terrain Park', 'N/A'),
                tubing_park=formatted_item.get('Tubing Park', 'N/A'),
                dining=formatted_item.get('Dining', 'N/A'),
                resort_description=formatted_item.get('Opening Paragraph', 'N/A'),
                resort_image_url=formatted_item.get('ImageURL', 'N/A'),
                extra_image_url=formatted_item.get('Extra Image URL', 'N/A'),
                video_url=formatted_item.get('Video', 'N/A')
            )
            
            return {
                'statusCode': 200,
                'body': html_content,
                'headers': {
                    'Content-Type': 'text/html',
                    'Access-Control-Allow-Origin': '*',
                    'Access-Control-Allow-Methods': 'GET,OPTIONS',
                    'Access-Control-Allow-Headers': 'Content-Type, x-api-key'
                }
            }
        else:
            return {
                'statusCode': 404,
                'body': json.dumps({'error': 'Ski resort not found'}),
                'headers': {
                    'Content-Type': 'application/json',
                    'Access-Control-Allow-Origin': '*',
                    'Access-Control-Allow-Methods': 'GET,OPTIONS',
                    'Access-Control-Allow-Headers': 'Content-Type, x-api-key'
                }
            }
    except Exception as e:
        print(f"Error fetching item from DynamoDB: {str(e)}")
        return {
            'statusCode': 500,
            'body': json.dumps({'error': str(e)}),
            'headers': {
                'Content-Type': 'application/json',
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Methods': 'GET,OPTIONS',
                'Access-Control-Allow-Headers': 'Content-Type, x-api-key'
            }
        }

enter image description here

Output

enter image description here

Problem:
When I test the API using Postman or a simple HTML page, I get the following response from my Lambda function:

json

{
    "statusCode": 400,
    "body": "{"error": "official_name parameter is required"}",
    "headers": {
        "Content-Type": "application/json",
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Methods": "GET,OPTIONS",
        "Access-Control-Allow-Headers": "Content-Type, x-api-key"
    }
}

Steps Taken:

Configured API Gateway:

Added official_name as a required query string parameter under Method Request.
Configured Integration Request with a mapping template to pass the official_name parameter to the Lambda function.
Tested with Postman:

Sent a GET request to

https://sjtdu9sez2.execute-api.us-east-1.amazonaws.com/deploy?official_name=Whitetail%20Resort


Received the 400 error indicating the parameter is missing.
enter image description here

Could anyone help me identify what I might be missing or doing wrong? How can I properly pass the official_name query string parameter to my Lambda function through API Gateway?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật