Closed Tr00d closed 1 year ago
When calling the StartAudioConnectorAsync method, a well-formed request will always return a 400 - Bad request.
StartAudioConnectorAsync
400 - Bad request
The problem happens during the request's serialization. The serialized request should look like this:
{ "sessionId": "OpenTok session ID", "token": "A valid OpenTok token", "websocket": { "uri": "wss://service.com/ws-endpoint", "streams": [ "streamId-1", "streamId-2" ], "headers": { "headerKey": "headerValue" }, "audioRate" : 8000 } }
But it looks like this:
{ "sessionId": "OpenTok session ID", "token": "A valid OpenTok token", "webSocket": { "Uri": "wss://service.com/ws-endpoint", "Streams": [ "streamId-1", "streamId-2" ], "Headers": { "headerKey": "headerValue" }, "AudioRate" : 8000 } }
Code snippet:
OpenTok openTok = new OpenTok(Config.GetApiKey(), Config.GetApiSecret()); openTok.StartBroadcast(sessionId); StreamList streams = openTok.ListStreams(sessionId); string token = openTok.GenerateToken(sessionId); var webSocket = new AudioConnectorStartRequest.WebSocket(new Uri("wss://xxx/"), streams.Select(s => s.Name).ToArray()); var startRequest = new AudioConnectorStartRequest(sessionId, token, webSocket); AudioConnector response = await openTok.StartAudioConnectorAsync(startRequest);
When calling the
StartAudioConnectorAsync
method, a well-formed request will always return a400 - Bad request
.The problem happens during the request's serialization. The serialized request should look like this:
But it looks like this:
Code snippet: