Skip to content

pydantic_core._pydantic_core.PydanticSerializationError: Error serializing to JSON: TypeError: 'MockValSer' object cannot be converted to 'SchemaSerializer' #265

@StanleyTack

Description

@StanleyTack

Trying to dump call list to json with this snippet

import os
from dotenv import load_dotenv
from retell import Retell
from retell.types import CallResponse, PhoneCallResponse, WebCallResponse, CallListResponse

load_dotenv()
retell_api_key = os.getenv("RETELL_API_KEY")
retell_agent_id = os.getenv("RETELL_AGENT_ID")
call_list_path = "data/call_list.json"

client = Retell(
    api_key=retell_api_key,
)

call_list: CallListResponse = client.call.list()

with open(call_list_path, "w") as json_file:
    for call in call_list:
        json_file.write(call.model_dump_json(indent=4))

print(f"Call list saved to {call_list_path}")

I get the error

Traceback (most recent call last):
  File "main.py", line 22, in <module>
    json_file.write(call.model_dump_json(indent=4))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/pydantic/main.py", line 477, in model_dump_json
    return self.__pydantic_serializer__.to_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.PydanticSerializationError: Error serializing to JSON: TypeError: 'MockValSer' object cannot be converted to 'SchemaSerializer'

Version:
retell-sdk-4.13.0
Python 3.12.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions