vonage-python-sdk icon indicating copy to clipboard operation
vonage-python-sdk copied to clipboard

fix: change ncco websocket endpoint contentType to content-type

Open rhbuckley opened this issue 1 year ago • 0 comments

When using the NCCO builder to create a Websocket Connect Endpoint, it serializes to have a field 'contentType', whilst the API expects a field of 'content-type'

Expected Behavior

{ "content-type": "...." }

Current Behavior

{ "contentType": "...." }

Possible Solution

Code

# Where BITRATE=16, and FREQUENCY=16000
ws = ConnectEndpoints.WebsocketEndpoint(
    uri=some_url,
    contentType=f"audio/l{StreamingConfig.BITRATE};rate={StreamingConfig.FREQUENCY}"
)

c = Ncco.Connect(endpoint=ws, eventType="synchronous")
ncco = Ncco.build_ncco(c)
print(json.dumps(ncco, indent=4))

Response to Voice API

[
    {
        "action": "connect",
        "endpoint": [
            {
                "type": "websocket",
                "uri": "wss://***.ngrok-free.app/ws",
                "contentType": "audio/l16;rate=8000"
            }
        ],
        "eventType": "synchronous"
    }
]

Websocket Connected Message

{
    "content-type": "audio/l16;rate=16000",
    "event": "websocket:connected"
}

After Applying Fix

{
    "content-type": "audio/l16;rate=8000",
    "event": "websocket:connected"
}

Your Environment

  • Version used: latest (bug can be seen in src)

rhbuckley avatar Feb 17 '24 15:02 rhbuckley