Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runtime.MarshalError in python

I am Getting this error. I am executing code of aws lambda function using python 3.7 to know quicksight dashboard version. Thanks in advance!

errorMessage: "Unable to marshal response: Object of type datetime is not JSON serializable",

errorType : "Runtime.MarshalError"

Code-

import boto3
import time
import sys
client = boto3.client('quicksight')
def lambda_handler(event, context):
    response = client.list_dashboard_versions(AwsAccountId='11111', DashboardId='2222',MaxResults=10)
    return response
like image 903
Ani Avatar asked Apr 19 '26 19:04

Ani


1 Answers

I quick fix could be:

import boto3
import time
import sys

import json

client = boto3.client('quicksight')

def lambda_handler(event, context):
    response = client.list_dashboard_versions(AwsAccountId='11111', DashboardId='2222',MaxResults=10)

    return json.dumps(response, default=str)
like image 161
Marcin Avatar answered Apr 22 '26 10:04

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!