Discussions

Ask a Question
Back to All

Building Talking Avatar demo on Next.js - Getting error 400 bad request on StartSession Function

Hello, I'm trying to run the example on a version of Next.js. I'm able to obtain the required information in exactly the following order (based on the example and documentation):

I upload the image and receive the ID of the new image (I successfully receive the response or "talk_photo").
I open the session with "NewSession" and pass it the parameters of the image and quality (I successfully receive the response).
I then pass the session response (the first two operations are executed on the server-side) to the client. From there, as the next step, I create the RTCPeerConnection and pass the ice_servers (this step is successful).
I then create the descriptions, both remote and local first because I need them to generate the onicecandidate (they are also generated successfully).
Once I have the descriptions, I call the StartSession function (because according to the documentation, I need to invoke it before calling "realtime ice"). When debugging in the browser, I see that I successfully pass the parameters session_id and sdp. However, this step (Start Session) fails. I get a 400 Bad Request response.
I reproduced the same steps in Insomnia with the parameters, and at this point, I always get a Bad Request with "Invalid request json body."

Regarding the ice, I also noticed that I successfully pass the candidates and the sessionID, but it never generates the video because, according to the documentation, I need the response from the StartSession function. Could someone provide an idea of what might be happening?

I also can provide the Id(If need it which does not belows to this account), more info about the code can be found also on https://stackoverflow.com/questions/77781071/heygen-talking-avatar-demo-migration-to-next-js-getting-400-bad-request-on-sta