I don't see my imported files in under saved object when using python request.POST

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
v 2.7.0

Describe the issue:
I am creating a small Python script to import dashboard into saved objects. I can do this manually via GUI and I can see my dashboards under `endpoint/_dashboards/app/management/opensearch-dashboards/objects

However importing the same file via python request, I can’t see this file even when I get status_code = 200. Another interesting thing is that when I examine the logs in Cloudwatch (my script is run by a Lambda function) I see the request is actually a GET rather than a POST. Has anyone seen this issue before


My simple lambda handler

def dashboard_import_lambda(event, context):

    # Define the path to the file to be uploaded
    file_path = 'dashboard_template/test_file_2.ndjson'
    # Define the OpenSearch endpoint URL
    opensearch_url = 'https://<end_point_url>/_dashboards/api/saved_objects/_import'

    # Define the headers for the POST request
    headers = {
        'kbn-xsrf': 'true',
        'Content-Type': 'application/x-ndjson',
        # Define the file to upload
        files = {
        'file': ('test_file.ndjson', open(file_path, 'rb'))

        # Make the POST request to import the file as a saved object
        response = requests.post(opensearch_url, headers=headers, files=files)
        # Check if the request was successful
        print(f'Request headers {response.request.headers}')
        print(f'Request method {response.request.method}')
        if response.status_code == 200:
            return {
                'statusCode': 200,
                'body': 'File imported Successfully.'
            return {
                'statusCode': response.status_code,
                'body': 'Failed to import the file as a saved object.'

Relevant Logs or Screenshots:

“statusCode”: 200,
“body”: “File imported Successfully.”

Request method GET

Finally findout the problem was that IAM role was missing Elasticsearch Service Policy Amazon Elasticsearch Service - Complete AWS IAM Reference for HTTP request